node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Retrieving headers from csv using nodejs

Open Sethu16 opened this issue 5 years ago • 2 comments

Hi I need to list all files from a S3 bucket and I need to list the headers of that file for that I used the below code it is not working is there any other way to achieve it

const AWS = require('aws-sdk') var csvHeaders = require('csv-headers')

const s3 = new AWS.S3({ accessKeyId:'----------------', secretAccessKey:'------------------------------', region:'ap-south-1' })

const params = { Bucket:'abcd-1' }

s3.listObjects(params,(err,data)=>{ if(err){ return console.log(err) } var options = { file : data.Contents.Keys, delimiter : ',' }; csvHeaders(options, function(err, headers) { if(!err) console.log(headers); }) });

Sethu16 avatar Jul 14 '20 07:07 Sethu16

Looks like you have the wrong library. this is csvtojson. If using this library you can use the .on('headers', (headers: string[]) => {})

blankstar85 avatar Jul 22 '20 21:07 blankstar85

@Sethu16 please close the issue

jfoclpf avatar Feb 10 '22 12:02 jfoclpf