No BSD License  

Highlights from
ECB Statistical Data Warehouse

ECB Statistical Data Warehouse

by

 

Download econometric time series from the ECB Statistical Data Warehouse.

fECBcsv(cKey)
function [vD vX] = fECBcsv(cKey)
% Download econometric time series from ECB SDW
%
% WARNINGS:
%   The root 'C:\' will be added!!!
%   A file 'c:\data.txt' will be generated and deleted!!!
%
% EXAMPLE: Consumer Price Index, France
%   [vD vX] = fECBcsv('ICP.M.FR.N.000000.4.INX');
%   plot(vD,vX); datetick('x')
%
% EMAIL: hanwufu@hotmail.com
%

% (0) 
mKey = {'ICP','122';... %Consumer Price Index
        'STS','132';... %Industrial Producer Prices
        };

mFrq = {'M','yyyymmm';... %Monthly data
        'A','yyyy'};      %Annual data
    
% (1a) Generate URL
cTmp = strread(cKey,'%s','delimiter','.');
cAdjKey = [ char( mKey( strcmp( mKey(:,1) , cTmp{1} ) ,2) ), '.', cKey];
sUrlname = ['http://sdw.ecb.europa.eu/export.do?exportType=csv&SERIES_KEY=',cAdjKey];

% (1b) Date format for (3)
cFormat= char(mFrq( strcmp( mFrq(:,1) , cTmp{2} ) ,2));

% (1c) Delete temporary variables
clear cTmp mKey cKey cAdjKey mFrq

% (2) Download .csv-file
path(path,'c:\');
urlwrite(sUrlname,'c:\data.txt'); 
[cD,cX] = textread('data.txt','%s %s','headerlines',3,'delimiter',',');
delete('c:\data.txt');

% (3) Transform Cell-Arrays, flip so vX(1) is the oldest observation 
vX = flipud(str2double(cX));
vD = flipud(datenum(cD,cFormat));
clear cX cD cFormat

end

Contact us