Skip to content

Commit

Permalink
account for bus/train/custom fields (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv authored Feb 17, 2024
1 parent 6596a7b commit 4b805db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/DataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export function exportCSV(data: any[]): string {
const values = Object.values(row).map((value) => {
if (typeof value === 'string') {
let stringValue = value.replace(/"/g, '""'); // Escape double quotes
if (stringValue.includes('#@-@#')) {
const busTrainSplit = stringValue.split('#@-@#');
stringValue = busTrainSplit[1];
}
if (stringValue.includes(',') || stringValue.includes('\n')) {
stringValue = `"${value}"`; // Quote fields containing commas or newlines
stringValue = `"${stringValue}"`; // Quote fields containing commas or newlines
}
return stringValue;
}
Expand Down

0 comments on commit 4b805db

Please sign in to comment.