node-csv
node-csv copied to clipboard
Getting the column names before entering a for await loop
Hello,
Could it be possible to have the information about columns before starting the for await of loop. Here is what I would like to do:
const parser = sourceStream.pipe(csv_parse({ columns: true, info: true }));
if (expectedColumnsAreFound(parser))
for await (const {record, info} of parser)
{
// process records
}
Of course, I could move the columns validity test inside the loop, but it would be tested for all records which is a waste of computation time in huge files.
I would set the columns to false, and handle it on my side. There is no current mechanism to handle this yet.
Summer cleanup. Closing for lack of activity.
Well, the request is still valid, just that I have not enough knowledge to offer a code change for this feature...
I suggested to handle the feature in the application code. The feature might never be accepted in the parser. Note I could change my mind.