Converts simple tabular data and allows additional columns to be added, either universally or based on the values in other columns.
Time | Label | Label | Label |
---|---|---|---|
{date values} | {data} | {data} | {data} |
{date values} | {data} | {data} | {data} |
{date values} | {data} | {data} | {data} |
Time | Values | Dimension |
---|---|---|
{date values} | {data} | {label} |
{date values} | {data} | {label} |
{date values} | {data} | {label} |
Instructions for MacOS
To install:
npm install
To run:
node script/convert.js {config-name} {input-filepath} {input-filename}
For example: node script/convert.js example http://127.0.0.1:8887/example/ example
Input files must be available from a full URI
The input describes the column title of the input CSV.
"input": ["Months", "Price ppl", "Volume (million litres)", "Butterfat (%)", "Protein (%)"],
Each column in the output CSV must be defined in the headers block in the following format.
{
"id": "date",
"title": "Months"
},
Additional columns must be added after the 3 required output columns.
In yor config file you can define additional columns and a specific value to add to each row of the CSV.
Note: ensure you also add a corresponding header and that the ID's match.
For example:
'additional'
{
"id": "example1"",
"value": "Test value"
},
and
'header'
{
"id": "example1",
"title": "Test"
},
Add values to a new column based on if they match another column. Column will be blank for any values that don't match.
{
"id": "unit",
"column":"measure",
"ifValue": "Price ppl",
"thenValue": "price"
},
Add an additional column by checking if a value matches another. If it doesn't match any of these values the 'else' value will be used.
{
"id": "geography",
"column": "date",
"ifValue": ["Sep-94", "Oct-94"],
"thenValue": "K03000001",
"else": "K02000001"
}
Currently checks up to 5 values entered in the ifValue array.