The data starts off in this shape:
[
{
date: "July 5, 2020"
name: "Calories"
symbol: "CALORIES"
value: 1,545.2
..,
},
{
date: "July 7, 2020"
name: "Total Carbs (g)"
symbol: "TOTAL_CARBS"
units: "g"
value: 45.2
..,
},
...
]
The intended shape of the outputted .csv
file should be:
--------------- 2020-07-05 2020-07-07 ...
Calories 1,545.2 1,6276.3 ...
Total Carbs (g) 45.2 56.9 ...
...
How should I transform the data before passing to the parsing function? to something like:
const transformedQueryData = [
{
'date': 2020-07-05,
'CALORIES': 1,545.2,
'TOTAL_CARBS': 45.2,
},
{
'date': 2020-07-07,
'CALORIES': 1,6276.3,
'TOTAL_CARBS': 56.9,
}
];
OR
const transformedQueryData = [
{
2020-07-05: {
'CALORIES': 1,545.2,
'TOTAL_CARBS': 45.2,
}
},
{
2020-07-07: {
'CALORIES': 1,6276.3,
'TOTAL_CARBS': 56.9,
}
}
];
OR can I use json2csv utilities and config to process the queriedData as it is?