3 ms·
I would call it a weakness of JS's ecosystem, not an ergonomic problem. I believe JS could allow nearly the same code. Haven't tried it, though: const fs = r
by jdlshore 8y ago
I would call it a weakness of JS's ecosystem, not an ergonomic problem. I believe JS could allow nearly the same code. Haven't tried it, though:
const fs = require("fs");
const csv = require("some-csv-package");
const incsv = csv.reader(fs.createReadStream("file1.csv"));
const outcsv = csv.writer(fs.createWriteStream("file2.csv"));
for await (row of incsv) {
await outcsv.writeRow([ row[0], `${row[1]} blah` ]);
}
Granted, that package doesn't exist, and the popular CSV package for Node [1] makes my eyes cross.
As for me, none of the scripting I do with Node involves files that exceed Node's 1GB memory limit, so I take the cheap and easy way out and just readFile(). Which I suppose proves your point, although, again, I would argue it's an ecosystem problem, not a ergonomic problem.
[1] https://csv.js.org/project/examples/ https://csv.js.org/project/examples/