It doesn't work. I asked GPT-4 to migrate the following PHP code to JS:
$csv = array_map('str_getcsv', file($argv[1]));
And this is the result: const csv = readFileSync(filename, 'utf-8').split('\n').map(line => line.split(','));
You can't parse CSV this way, because you need to respect delimiters. Counter example: 1,"1,5",2
"1,5" being the German notation for "1.5". Hence, a simple split(',') will break this thing.PHP's str_getcsv is, of course, a proper CSV parser and not a string splitter. Unless your code uses basically zero stdlib API calls, you will have to double check everything.
Please note that this kind of bug isn't even easy to catch if you test CSV file doesn't contain a quoted entry.