I don't understand why the last console.log returns 'Promise { pending }' without any log. When I can see the result when I uncomment the console.log in the GetInfo function. How can I fix that issue and get my records array from GetInfo?
const fs = require("fs")
const { parse } = require("csv-parse")
const processFile = async () => {
const records = []
const parser = fs.createReadStream("bom.csv").pipe(
parse({
delimiter: ",",
columns: ["BoMLevel","Level","Item","Desc","Type","Count"],
})
)
for await (const record of parser) {
records.push(record)
}
return records
}
async function GetInfo() {
const records = await processFile()
// console.info(records)
return records
}
console.log(GetInfo())