Retrieving headers from csv using nodejs
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); }) });
Looks like you have the wrong library. this is csvtojson. If using this library you can use the .on('headers', (headers: string[]) => {})
@Sethu16 please close the issue