Reproduction code
import { createObjectCsvWriter } from 'csv-writer';
const csvPath = 'test.csv'
const csvWriter = createObjectCsvWriter({
path: csvPath,
header: [
{ id: 'phone_number', title: 'phone_number' },
{ id: 'name', title: 'name' },
{ id: 'email', title: 'email' },
],
});
let data = [{ phone_number: 9978789799, name: "John Doe \r", email: "johndoe@email.com" }, {phone_number: 8898988989, name: "Bob Marlin", email: "bormarlin@email.com"}]
await csvWriter.writeRecords(data);
The resultant output is not a valid CSV. Checked with CSV Validator Tool
The output
phone_number,name,email
9978789799,John Doe
,johndoe@email.com
8898988989,Bob Marlin,bormarlin@email.com
Reproduction code
The resultant output is not a valid CSV. Checked with CSV Validator Tool
The output