From 061c9a79571dcb33a2eee725b8ee86f177bc3459 Mon Sep 17 00:00:00 2001 From: Patrick Joyce Date: Sat, 17 Feb 2024 16:16:44 -0500 Subject: [PATCH] account for bus/train/custom fields --- src/lib/DataUtils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/DataUtils.ts b/src/lib/DataUtils.ts index 1145124..6bfde26 100644 --- a/src/lib/DataUtils.ts +++ b/src/lib/DataUtils.ts @@ -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; }