Created
December 16, 2021 11:00
-
-
Save artyomliou/32760d341297b4bb8c0404cfc4d17062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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