We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thank you for your package. I just started using it today. I have a question about my probable misunderstanding of use stream.
Here are my 2 different experiments with the file:
1st test: const csv=require('csvtojson') csv({includeColumns:/(nom|insee)/, colParser:{"insee":"string"}, checkType:true}) .fromFile("test.csv") .then(jsonObj => fs.writeFile("result.json", JSON.stringify(jsonObj), (err) => {if (err) return console.log(err);}))
------ result.json [{"nom":"Marseille","insee":"13055"},{"nom":"Paris","insee":"75000"}]
Correct answer as expected.
but
2nd test: const csv=require('csvtojson') const fs = require('fs'); fs.createReadStream("test.csv") .pipe(csv({includeColumns:/(nom|insee)/, colParser:{"insee":"string"}, checkType:true})) .pipe(fs.createWriteStream("result.json"));
------ result.json {"nom":"Marseille","insee":"13055"} {"nom":"Paris","insee":"75000"}
Not quite correct (missing comma between objects and overall sqare brackets) I don't see where I am wrong in second piece of code.
Thank you for your assistance. Best regards Robert.
The text was updated successfully, but these errors were encountered:
I'm getting the same results when I try to pipe fs.createReadStream to fs.createWriteStream
fs.createReadStream
fs.createWriteStream
Sorry, something went wrong.
developed with downstreamFormat parameters
@Keyang I can't make it work. What Im doing wrong #467
Keyang
No branches or pull requests
Thank you for your package.
I just started using it today.
I have a question about my probable misunderstanding of use stream.
Here are my 2 different experiments with the file:
------ test.csv
nom,insee,pop
Marseille,13055,800000
Paris,75000,25000000
1st test:
const csv=require('csvtojson')
csv({includeColumns:/(nom|insee)/, colParser:{"insee":"string"},
checkType:true})
.fromFile("test.csv")
.then(jsonObj => fs.writeFile("result.json", JSON.stringify(jsonObj),
(err) => {if (err) return console.log(err);}))
------ result.json
[{"nom":"Marseille","insee":"13055"},{"nom":"Paris","insee":"75000"}]
Correct answer as expected.
but
2nd test:
const csv=require('csvtojson')
const fs = require('fs');
fs.createReadStream("test.csv")
.pipe(csv({includeColumns:/(nom|insee)/,
colParser:{"insee":"string"}, checkType:true}))
.pipe(fs.createWriteStream("result.json"));
------ result.json
{"nom":"Marseille","insee":"13055"}
{"nom":"Paris","insee":"75000"}
Not quite correct
(missing comma between objects and overall sqare brackets)
I don't see where I am wrong in second piece of code.
Thank you for your assistance.
Best regards
Robert.
The text was updated successfully, but these errors were encountered: