Transforming JS object to CSV
cowchimp opened this issue · 1 comments
cowchimp commented
Hi.
With the split to data-forge
and data-forge-fs
, I'm not sure how to turn an array of JS Objects I have in memory into a CSV file.
fromObject()
is defined on data-forge
but asCSV()
and writeFileSync()
are defined in data-forge-fs
.
Example data structure
const arr = [
{ first: 'micky', last: 'mouse' },
{ first: 'minnie', last: 'mouse' }
];
// How do I turn `arr` into a CSV file?
// Do i import `data-forge` or `data-forge-fs` or both?
Thank you.
ashleydavis commented
After the split you need to include both data-forge
and data-forge-fs
. That's it, that's all you have to do differently:
const dataForge = require("data-forge");
require("data-forge-fs");
// You code goes here
There are multiple ways to get your data into a DataFrame.
You can read about how to write CSV files in The Guide.
Please let me know if any part of it isn't clear.