template<typename S, typename ... Ts>
bool
write(S &o, bool values_only = false, io_format iof = io_format::csv) const;
|
It outputs the content of DataFrame into the stream o. Currently two formats (i.e. csv, json) are supported specified by the iof parameter.
The csv file format must be:
INDEX:<Number of data points>:<Comma delimited list of values>
<Column1 name>:<Number of data points>:<Column1 type>:<Comma delimited list of values>
<Column2 name>:<Number of data points>:<Column2 type>:<Comma delimited list of values>
.
.
.
All empty lines or lines starting with # will be skipped.
The JSON file format looks like this:
{
"INDEX":{"N":3,"T":"ulong","D":[123450,123451,123452]},
"col_3":{"N":3,"T":"double","D":[15.2,16.34,17.764]},
"col_4":{"N":3,"T":"int","D":[22,23,24]},
"col_str":{"N":3,"T":"string","D":["11","22","33"]},
"col_2":{"N":3,"T":"double","D":[8,9.001,10]},
"col_1":{"N":3,"T":"double","D":[1,2,3.456]}
}
Please note DataFrame json does not follow json spec 100%. In json, there is no particular order in dictionary fields. But in DataFrame json:
- Column “INDEX” must be the first column
- Fields in column dictionaries must be in N, T, D order
|
S: Output stream type
Ts: The list of types for all columns. A type should be specified only once.
o: Reference to an streamable object (e.g. cout)
values_only: If true, the name and type of each column is not written
iof: Specifies the I/O format. The default is CSV
|