|
Hello ppl,
is there a way to fetch easily data from the ECB SDW ( http://sdw.ecb.europa.eu/) - The data is for free!!!
Currently, I am using simply urlwrite.m and textread.m to download .csv-Files. However, it's possible to use .xml as well.
It would be very convient to fetch data like from the FRED2 database (see fred.m, Database Toolbox; Federal Reserve St.Louis!) - Something nice, stable and fast????
Some Explanation: The function below download .csv text files. The first 3 lines includes about the dataset blabla stuff. THE BIG PROBLEM is that the SERIES_KEY published by ECB SDW isn't sufficient to download the dataset - There is an additional 3-digit number required (look at 'mKey'). These digits you can figure out after downloading a dataset manually - Not nice.
HAVE ANYONE AN IDEA HOW TO UTILIZE THE ECB SDW MORE EFFICIENTLY???
EXAMPLE: French CPI
[vD vX] = fECBcsv('ICP.M.FR.N.000000.4.INX');
plot(vD,vX); datetick('x')
CODES:
function [vD vX] = fECBcsv(cKey)
%
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 (4)
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');
% (4) 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
|