Validating the fast-Csv headers

13 views
Skip to first unread message

Hanuman Bandhu

unread,
May 26, 2017, 2:32:33 PM5/26/17
to nodejs

Hi Friends , I stuck with reading a csv file using the fast -csv option .

I need to validate the header names of csv file before uploading but I am not getting a way to do it ..

Could you guys help me out .

csv
.fromStream(file, {headers :true})
.on("error", function(data){
sendWrongHeadersResponse(res);
})
.on("data", function(data){
uploadtoDB(data);
});

function sendWrongHeadersResponse(){

res.send("invalid headers found");
}

My CSV file should have header1, header2 , header3 and header4 and no other fileds

Reply all
Reply to author
Forward
0 new messages