Thank you for providing great JSON to CSV converter.
We are getting trouble with specifying columns that are flattened by transforms: [flatten({ arrays: true })].
Details are shown below.
Filing an issue
Include the version of json2csv used.
7.0.1
Include your node version/browser vendor and version.
18.9.1
Include the command or code you used.
import { Parser } from "@json2csv/plainjs"
import { flatten } from "@json2csv/transforms"
const data = [
{
car: "Audi",
price: 40000,
color: ["black", "blue"], # The length of the array is unknown until it is processed.
},
{
car: "BMW",
price: 35000,
color: ["red", "blue"], # The length of the array is unknown until it is processed.
},
]
The length of the array is unknown until it is processed, so we cannot set fields argument like `["car", "color.0", "color.1"]`.
We are looking for the solution.
Thank you.
Thank you for providing great JSON to CSV converter. We are getting trouble with specifying columns that are flattened by
transforms: [flatten({ arrays: true })]
. Details are shown below.Filing an issue
Include the version of json2csv used. 7.0.1
Include your node version/browser vendor and version. 18.9.1
Include the command or code you used.
const data = [ { car: "Audi", price: 40000, color: ["black", "blue"], # The length of the array is unknown until it is processed. }, { car: "BMW", price: 35000, color: ["red", "blue"], # The length of the array is unknown until it is processed. }, ]
const fields: Array = ["car", "color"]
const parser = new Parser({ fields: fields, transforms: [flatten({ arrays: true })] }) const csv = parser.parse(data) console.log(csv)
"car","color.0","color.1" "Audi","black","blue" "BMW","red","blue"
"car","color" "Audi", "BMW",