I am trying to convert csv to json. This CSV contains emojis, i guess that might be the problem.
csvtojson or any other module or even any custom method is returning unknown characters/garbage characters. My csv file link below:
The code i am using is:
let csvFilePath = path.join(\__dirname, 'reports/xyz.csv');
let str1 = fs.readFileSync(csvFilePath, { encoding: 'utf8' }).toString();
csv({noheader:true,output: "csv"}).fromString(str1).then((csvRow)=\>{console.log(csvRow)});
It is returning a bunch of \x00c\x00o\x00m\x00.\x00b\x00h\x00a\x00k\x00t\x00 characters.
I have tried to print your csv file in console and it indeed shows unicode character identifier.
The problem is not with
csvtojsonmodule rather with the csv.I have opened webstorm debugger while running your code. This is the first line of your csv as json object. See the vertical lines between each character both in every key and value of the row object. This is a problem with the format of the csv and the software used to write it. The csv you provided has invisible characters. I don't actually know why this would be present in all of the characters but it does exist in the file.
Now for your options: