Skip to content
New issue

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

big csv #79

Closed
sureshvarman opened this issue Feb 18, 2016 · 2 comments
Closed

big csv #79

sureshvarman opened this issue Feb 18, 2016 · 2 comments

Comments

@sureshvarman
Copy link

I'm having 1 million records of CSV file, I need to apply some transform on each record, how can I achieve this with read and write stream

@Keyang
Copy link
Owner

Keyang commented Feb 18, 2016

Hi,
Take a look at this:
https://github.com/Keyang/node-csvtojson#synchronouse-transformer
some example:

var Converter=require("csvtojson").Converter;
var csvConverter=new Converter({constructResult:false}); //important to
turn off result construction

csvConverter.transform=function(json,row,index){
    json["rowIndex"]=index;
    /* some other examples:
    delete json["myfield"]; //remove a field
    json["dateOfBirth"]=new Date(json["dateOfBirth"]); // convert a field
type
    */
};

var rs=require("fs").createReadStream("./millionsRows.csv");
rs.pipe(csvConverter)
//.pipe(downstream)

~Keyang

On 18 February 2016 at 17:49, suresh varman notifications@github.com
wrote:

I'm having 1 million records of CSV file, I need to apply some transform
on each record, how can I achieve this with read and write stream


Reply to this email directly or view it on GitHub
#79.

@sureshvarman
Copy link
Author

thanks for the quick response, previously the transform was not working, so we were using the "end_parsed" we faced a problem while processing the csv file of 125 MB its because we were using the version 0.4.5 now the problem is been resolved by upgrading to newer version. i am closing this thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants