We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30f12bf commit d9499ceCopy full SHA for d9499ce
README.md
@@ -109,6 +109,27 @@ fs.createReadStream('data.csv')
109
});
110
```
111
112
+You can also use async iterators in modern Node.js versions:
113
+
114
+```js
115
+import csv from 'csv-parser';
116
+import fs from 'node:fs';
117
118
+async function readCSV(file) {
119
+ const result = [];
120
121
+ for await (const data of fs.createReadStream(file).pipe(csv())) {
122
+ result.push(data);
123
+ }
124
125
+ return result;
126
+}
127
128
+readCSV('data.csv')
129
+ .then((results) => console.log(results))
130
+ .catch((err) => console.error(err));
131
+```
132
133
To specify options for `csv`, pass an object argument to the function. For
134
example:
135
0 commit comments