const csvDataFormatted = csvData.map(item => {
return cols.reduce((acc, col) => {
const value = item[col.key];
if (dateFields.includes(col.key)) {
const date = new Date(value);
acc[col.key] = isNaN(date.getTime()) ? value : format(date, 'dd-MM-yyyy');
}
else {
acc[col.key] = value;
}
return acc;
}, {});
});
const csv = Papa.unparse([
cols.map(col => col.header),
...csvDataFormatted.map(item => cols.map(col => item[col.key]))
]);
When exporting the csv file the value of schoolID was 2.60724E+18 instead of 2607241007009180000.
What I did is add this condition
if (col.key === 'schoolID') {
acc[col.key] = value ? `'${value}` : '';
}
but the single quote shouldn’t be included.
4