Reputation: 141
with the below code I expect to see records being printed. But I get radio silence. No error or any records being printed.
CSV file content and located in same folder as index.js
userId,prefChannel
1,push.pref
2,email.pref
3,email.pref
4,email.pref
5,push.pref
6,push.pref
7,email.pref
8,push.pref
9,email.pref
10,push.pref
csv version is:
"dependencies": {
"csv": "^6.2.0"
}
index.js code:
const fs = require("fs");
const { parse } = require('csv-parse');
async function readRecordsFromCSV() {
const cvsFileName = (__dirname + SETTINGS.filePath);
console.info(chalk.green(`Streaming file: ${cvsFileName}`));
// read csv file
const parser = parse({delimiter: ','}, function(err, data){
console.log(data);
console.log(err);
});
fs.createReadStream(cvsFileName).pipe(parser);
}
// driver code:
// Run the script
; (async function () {
// read and transform all items from csv file
const newPrefs_1 = await transformPreferenceRecordsFromCSV();
})()
I will start the script by passing in the file name and here is my test output:
**Streaming file: {correct file path}/.../bq-results-10-records-test.csv**
Upvotes: 0
Views: 160
Reputation: 141
The code in question actually works. My local has this at the end of the driver code which caused it to terminate early.
process.exit(1);
Upvotes: 0