databank.fromSheet
(+databank)
Load databank of time series from an XLSX or CSV file
Syntax
[outputDb, names] = databank.fromSheet(fileName, ___)
Input arguments
fileName
[ string ]
File name from which the time series will be loaded into the
outputDb
.
Output arguments
names
[ string ]
List of databank fields actually saved to the output file.
Options
AddToDatabank=struct()
[ struct ]
Add the time series from the
fileName
file to this databank.
IncludeComments=true
[ true
| false
]
If
IncludeComments=true
, comments are expected to exist in a second row of the file header (underneath the variables names), and will be read in and assigned to the resulting time series.
Frequencies
[ @all
| Frequency ]
List of date frequencies; only time series with date frequencies on this list will be loaded;
Frequencies=@all
means all date frequencies.
Sheet=1
[ numeric | string ]
Only in Excel spreadsheet files: specification of the sheet to read.
SourceNames=@all
[ @all
| string ]
List of time series fields from the
inputDb
that will be loaded;SourceNames=@all
means all time series found in thefileName
file.
TargetNames=[]
[ empty | function | struct ]
Function or mapping to transform the source names in the file to target field names used in the
outputDb
; ifTargetNames=[]
, the time series will be saved under the source names.
Description
The databank.toSheet
and its reading counterpart databank.toSheet
handle multiple date frequencies by grouping the time series of the same
frequency, and loading/saving these groups from/to a single sheet.
At the moment, only numeric time series with real values are supported in
databank.toSheet
and databank.fromSheet
.
Examples
d = struct();
d.x = Series(yy(2020):yy(2030), 1);
d.y = Series(mm(2020,01):mm(2020,12), rand(12, 4));
databank.toSheet(d, "test.csv");
d1 = databank.fromSheet("test.csv");
databank.fromSheet(d, "test.xlsx");
d2 = databank.fromSheet("test.xlsx");