-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_data_covid_argentina.m
96 lines (72 loc) · 3.28 KB
/
get_data_covid_argentina.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function [tableConfirmed,tableDeaths,tableRecovered,time] = get_covid_argentina( source, directory )
% get_covid_global_hopkins() gets global data from the COVID-19 epidemy from the
% John Hopkins university [1]. Source can be online or offline.
% Based on E. Cheynet's work [2].
%
% References:
% [1] https://github.com/CSSEGISandData/COVID-19
% [2] https://www.mathworks.com/matlabcentral/fileexchange/74545-generalized-seir-epidemic-model-fitting-and-computation
%
% Version: 001
% Date: 2020/04/01
% Author: Rodrigo Gonzalez <rodralez@frm.utn.edu.ar>
% URL: https://github.com/rodralez/navego
%% Input handling
if nargin < 1
source = 'offline';
directory = './';
end
if ( strcmp (source, 'online'))
%% Import the data
status = {'confirmed','deaths','recovered'};
server = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/';
% https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/
for i=1:numel(status)
filename = [directory,'time_series_covid19_',status{i},'_global.csv'];
url = [server,'time_series_covid19_',status{i},'_global.csv'];
websave( filename, url );
opts = detectImportOptions(filename);
opts.VariableNames(1) = {'ProvinceState'};
opts.VariableNames(2) = {'CountryRegion'};
opts.VariableNames(3) = {'Population'};
opts.VariableNames(4) = {'Long'};
% opts.HeaderLines = 1;
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
if strcmpi(status{i},'Confirmed')
tableConfirmed = readtable(filename, opts);
tableConfirmed = tableConfirmed(2:end,:); % First line is header and is descarted
tableConfirmed.Long = []; % Long column is descarted
tableConfirmed = improve_covid_global_hopkins( tableConfirmed );
elseif strcmpi(status{i},'Deaths')
tableDeaths = readtable(filename, opts);
tableDeaths = tableDeaths(2:end,:); % First line is header and is descarted
tableDeaths.Long = []; % Long column is descarted
tableDeaths = improve_covid_global_hopkins( tableDeaths );
elseif strcmpi(status{i},'Recovered')
tableRecovered = readtable(filename, opts);
tableRecovered = tableRecovered(2:end,:); % First line is header and is descarted
tableRecovered.Long = []; % Long column is descarted
tableRecovered = improve_covid_global_hopkins( tableRecovered );
else
error('Unknown status')
end
end
%% TIME
fid = fopen(filename);
time_str = textscan( fid, repmat('%s', 1, size(tableConfirmed,2)+1 ), 1, 'Delimiter',',');
time = datetime( [time_str{5:end}] ) + years(2000);
fclose(fid);
save tableConfirmed tableConfirmed
save tableRecovered tableRecovered
save tableDeaths tableDeaths
save time time
elseif (strcmp (source, 'offline') )
load tableConfirmed
load tableRecovered
load tableDeaths
load time
else
error('get_covid_global_hopkins: bad source.')
end