Skip to content
Snippets Groups Projects
Commit a41c7641 authored by Dóra Kocsis's avatar Dóra Kocsis
Browse files

Cosmetics

parent e0ee6dae
No related branches found
No related tags found
No related merge requests found
[![pipeline status](https://git.dynare.org/DoraK/mdbnomics/badges/master/pipeline.svg)](https://git.dynare.org/DoraK/mdbnomics/commits/master) [![pipeline status](https://git.dynare.org/DoraK/mdbnomics/badges/master/pipeline.svg)](https://git.dynare.org/DoraK/mdbnomics/commits/master)
This MATLAB/Octave toolbox comes with routines to access DBnomics time series from MATLAB. This MATLAB toolbox comes with routines to access DBnomics time series from MATLAB.
The package is compatible with MATLAB 2019b and following versions, and (almost compatible with) The package is compatible with MATLAB 2019b and following versions.
the latest Octave version. Octave compability will follow after the release of Octave 6 (an implementation to webread/webwrite/jsondecode is required).
## Installation ## Installation
...@@ -19,12 +19,12 @@ or downloading a zip archive: ...@@ -19,12 +19,12 @@ or downloading a zip archive:
## Usage ## Usage
Add the `mdbnomics/src` folder to the MATLAB/Octave path, and run the following command (on MATLAB/Octave) prompt: Add the `mdbnomics/src` folder to the MATLAB path, and run the following command (on MATLAB) prompt:
>> initialize_mdbnomics() >> initialize_mdbnomics()
which, depending on your system, will add the necessary subfolders to which, depending on your system, will add the necessary subfolders to
the MATLAB/Octave path. the MATLAB path.
You are then ready to go. A full documentation will come soon. You are then ready to go. A full documentation will come soon.
......
% fetch series by provider code and dataset code % fetch series by provider code and dataset code
test = fetch_series('provider_code', 'AMECO', 'dataset_code', 'UVGD', 'max_nb_series', 500); test = fetch_series('provider_code', 'AMECO', 'dataset_code', 'UVGD', 'max_nb_series', 50);
ds = to_dseries(df); ds = dbnomics_to_dseries(test);
% fetch one series by ID % fetch one series by ID
df_id = fetch_series('series_ids','AMECO/ZUTN/EA19.1.0.0.0.ZUTN'); df_id = fetch_series('series_ids','AMECO/ZUTN/EA19.1.0.0.0.ZUTN');
ds_id = to_dseries(df_id); ds_id = dbnomics_to_dseries(df_id);
% fetch multiple series by ID % fetch multiple series by ID
df_ids = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN'}); df_ids = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN'});
ds_ids = to_dseries(df_ids); ds_ids = dbnomics_to_dseries(df_ids);
% fetch many series by ID from different datasets % fetch many series by ID from different datasets
df_ids_sets = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN', 'IMF/CPI/A.AT.PCPIT_IX'});
ds_ids_sets = dbnomics_to_dseries(df_ids_sets);
% fetch time series by code mask % fetch time series by code mask
df_code_mask1 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M.FR+DE.PCPIEC_IX+PCPIA_IX'); df_code_mask1 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M.FR+DE.PCPIEC_IX+PCPIA_IX');
ds_code_mask1 = to_dseries(df_code_mask1); ds_code_mask1 = dbnomics_to_dseries(df_code_mask1);
df_code_mask2 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', '.FR.PCPIEC_WT'); df_code_mask2 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', '.FR.PCPIEC_WT');
ds_code_mask2 = to_dseries(df_code_mask1); ds_code_mask2 = dbnomics_to_dseries(df_code_mask2);
% df_code_mask3 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M..PCPIEC_IX+PCPIA_IX', 'max_nb_series', 400); % df_code_mask3 = fetch_series('provider_code', 'IMF', 'dataset_code', 'CPI', 'series_code', 'M..PCPIEC_IX+PCPIA_IX', 'max_nb_series', 400);
% fetch series by dimensions % fetch series by dimensions
df_dim = fetch_series('provider_code','AMECO', 'dataset_code', 'ZUTN', 'dimensions', '{"geo":["dnk"]}'); df_dim = fetch_series('provider_code','AMECO', 'dataset_code', 'ZUTN', 'dimensions', '{"geo":["dnk"]}');
ds_dim = to_dseries(df_dim); ds_dim = dbnomics_to_dseries(df_dim);
df_dims = fetch_series('provider_code','WB','dataset_code','DB', 'dimensions', '{"country":["ES","FR","IT"],"indicator":["IC.REG.COST.PC.FE.ZS.DRFN"]}'); df_dims = fetch_series('provider_code','WB','dataset_code','DB', 'dimensions', '{"country":["ES","FR","IT"],"indicator":["IC.REG.COST.PC.FE.ZS.DRFN"]}');
ds_dims = to_dseries(df_dims); ds_dims = dbnomics_to_dseries(df_dims);
% fetch series by api link % fetch series by api link
df_link = fetch_series_by_api_link('https://api.db.nomics.world/v22/series/WB/DB?observations=1&dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%2C%22indicator%22%3A%5B%22IC.REG.COST.PC.FE.ZS.DRFN%22%5D%7D'); df_link = fetch_series_by_api_link('https://api.db.nomics.world/v22/series/WB/DB?observations=1&dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%2C%22indicator%22%3A%5B%22IC.REG.COST.PC.FE.ZS.DRFN%22%5D%7D');
ds_link = to_dseries(df_link); ds_link = dbnomics_to_dseries(df_link);
% fetch series from the cart % fetch series from the cart
df_cart = fetch_series_by_api_link('https://api.db.nomics.world/v22/series?series_ids=AMECO%2FZUTN%2FEA19.1.0.0.0.ZUTN&observations=1'); df_cart = fetch_series_by_api_link('https://api.db.nomics.world/v22/series?series_ids=AMECO%2FZUTN%2FEA19.1.0.0.0.ZUTN&observations=1');
ds_cart = to_dseries(df_cart); ds_cart = dbnomics_to_dseries(df_cart);
%%
% fetch many series by ID from different datasets
df_ids_sets = fetch_series('series_ids', {'AMECO/ZUTN/EA19.1.0.0.0.ZUTN', 'AMECO/ZUTN/DNK.1.0.0.0.ZUTN', 'IMF/CPI/A.AT.PCPIT_IX'});
ds_ids_sets = to_dseries(df_ids_sets);
% fetch multi frequency series % fetch multi frequency series
df_multi_freq = fetch_series('series_ids', {'BEA/NIUnderlyingDetail-U001BC/S315-A',... df_multi_freq = fetch_series('series_ids', {'BEA/NIUnderlyingDetail-U001BC/S315-A',...
......
...@@ -278,7 +278,7 @@ end ...@@ -278,7 +278,7 @@ end
%$ t(3) = dassert(df(2,2), {'AMECO'}); %$ t(3) = dassert(df(2,2), {'AMECO'});
%$ t(4) = dassert(length(unique(df(2:end,3))),1); %$ t(4) = dassert(length(unique(df(2:end,3))),1);
%$ t(5) = dassert(df(2,3), {'ZUTN'}); %$ t(5) = dassert(df(2,3), {'ZUTN'});
%$ t(6) = dassert(length(unique(df(2:end,5))), 49); %$ t(6) = dassert(length(unique(df(2:end,5))), 48);
%$ end %$ end
%$ %$
%$ T = all(t); %$ T = all(t);
......
...@@ -86,7 +86,12 @@ else ...@@ -86,7 +86,12 @@ else
series_list = [series_list, filtered_series_list]; series_list = [series_list, filtered_series_list];
end end
df = cell(length(series_list{1}.value)*length(series_list)+1,length(ordered_columns_names)); %%%%%%% OPTIMIZE SIZE PRE-ALLOCATION %%%%%%%
rows_ = 0;
for s = 1:length(series_list)
rows_ = rows_ + length(series_list{s}.value);
end
df = cell(rows_+1,length(ordered_columns_names));
df(1,:) = ordered_columns_names; df(1,:) = ordered_columns_names;
series_length=0; series_length=0;
......
...@@ -30,10 +30,7 @@ function series = normalize_value(series) ...@@ -30,10 +30,7 @@ function series = normalize_value(series)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if iscell(series.value) if iscell(series.value)
% series.original_value = cellfun(@char, series.value, 'UniformOutput', false);
series.original_value = cellfun(@num2str,series.value,'un',0); series.original_value = cellfun(@num2str,series.value,'un',0);
% series.original_value = char(series.value);
series.value(strcmp(series.value, 'NA')) = {NaN}; series.value(strcmp(series.value, 'NA')) = {NaN};
else else
series.original_value = num2cell(series.value); series.original_value = num2cell(series.value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment