Novice in node.js here. I am using csvtojson
to read a csv into an object fileDataObject
, like that:
const csv=require("csvtojson");
csv(
{
delimiter:mq.delim
,trim:false
}
)
.fromFile(mq.folder_pending+'\\'+file)
.then((fileDataObject)=>{
What I'd like is for fileDataObject
to have an additional "column" (property) named row_number
, which indicates the source line number of the file.
The documentation mentions something about a file line hook, but I don't know how to use hooks.
There is already an example on the package readme.
Once you get your
fileDataObject
(in your example), you can simply add a column keyFor example
For your example