From b00910c8933e1288d832a8fc5a6e5c46c7b6cbe1 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 18 Nov 2024 16:29:36 +0100 Subject: [PATCH] Add support for quotes in CSV parser tool --- pages/tools/csv-parser-json-converter.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/tools/csv-parser-json-converter.tsx b/pages/tools/csv-parser-json-converter.tsx index 09f91df2..fc43d707 100644 --- a/pages/tools/csv-parser-json-converter.tsx +++ b/pages/tools/csv-parser-json-converter.tsx @@ -114,11 +114,15 @@ Alice,35,Chicago,Data Scientist,Amazon,Seattle,345-678-9012`; } if (index === 0) { - headers = line.split(','); + headers = line + .split(',') + .map((item) => item.trim().replace(/^"(.*)"$/, '$1')); return; } else { - const items = line.split(','); + const items = line + .split(',') + .map((item) => item.trim().replace(/^"(.*)"$/, '$1')); lines.push(items); }