I try this const csvFile = require("pathtocsv.csv")
But it give me an error:
pathtocsv.csv:18
return,100,physical,null,0,selected-pokemon,normal
^
SyntaxError: Unexpected token ,
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
I try to do some console.log to check where the error start, and it started on the beginning with the require.
I try to modify my csv I replace coma with semi-column but nothing happen the error is not the same but it's exactly the same type of error but on another line:
brick-break;100;physical;75;0;selected-pokemon;fighting
^^^^^
fs.readFileSync. You can use likeconst fs = require("fs"); const fileContent = fs.readFileSync("./pathtocsv.csv");That will give you an arrayBuffer. Depending on the content you might be able to just callString(file)or you may need to do something else (if it isn't just text or if it has some encoding).