Skip to content

Instantly share code, notes, and snippets.

@artyomliou
Created December 16, 2021 11:00
Show Gist options
  • Save artyomliou/32760d341297b4bb8c0404cfc4d17062 to your computer and use it in GitHub Desktop.
Save artyomliou/32760d341297b4bb8c0404cfc4d17062 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const { parse } = require('csv-parse');
async function* readCsvFile(filepath) {
const parser = fs.createReadStream(filepath).pipe(
parse({
columns: true,
skipEmptyLines: true,
trim: true
})
);
for await (const record of parser) {
yield record;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment