Stream of records
This function automatically sets the file name as the error source for better error reporting (unless explicitly overridden via options).
import { parseFileToStream } from 'web-csv-toolbox';
const input = document.querySelector('input[type="file"]');
input.addEventListener('change', async (event) => {
const file = event.target.files[0];
await parseFileToStream(file)
.pipeTo(
new WritableStream({
write(record) {
console.log(record);
},
}),
);
});
Parse CSV from a File to stream of records.