Read and Write Data
When loading data with readMatrix()/readFrame() in a DaphneDSL script, the system expects a file with the same file name in the same
directory as the data file with an additional extension .meta. This file contains a description of meta data stored
in JSON format.
There are two slightly varying ways of specifying meta data depending on whether there is a schema for the columns (e.g.,
a data frame - the corresponding C++ type is the Frame class) or not (this data can currently be
loaded as DenseMatrix<VT> or CSRMatrix<VT> where VT is the value type template parameter).
If data is written from a DaphneDSL script via write()/writeMatrix()/writeFrame(), the meta data file will be written to the corresponding filename.meta.
Currently Supported JSON Fields
| Name | Expected Data | Allowed values |
|---|---|---|
| numRows | Integer | number of rows |
| numCols | Integer | number of columns |
| valueType | String | si8, si32, si64, // signed integers (intX_t)ui8, ui32, ui64, // unsigned integers (uintX_t)f32, f64, // floating point (float, double)str // stringContained within schema this may be an empty string. In this case all columns of a data frame will have the same valueType defined outside of the schema data field |
| numNonZeros | Integer | number of non-zeros (optional) |
| schema | JSON | nested elements of "label" and "valueType" fields |
| label | String | column name/header (optional, may be empty string "") |
Matrix Example
The example below describes a 2x4 matrix of double-precision values.
Matrix CSV
Matrix Metadata
Data Frame Example
The example below describes a 2x2 frame with signed integers in the first column named foo and double-precision values in the second column named bar.
Data Frame CSV
Data Frame Metadata
{
"numRows": 2,
"numCols": 2,
"schema": [
{
"label": "foo",
"valueType": "si64"
},
{
"label": "bar",
"valueType": "f64"
}
]
}
Data Frame Meta Data with Default ValueType
{
"numRows": 5,
"numCols": 3,
"valueType": "f32",
"schema": [
{
"label": "a",
"valueType": ""
},
{
"label": "bc",
"valueType": ""
},
{
"label": "def",
"valueType": ""
}
]
}