From 5fa3aa35506050989db84741382108ccb6453d5e Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Fri, 1 Dec 2023 17:17:45 +0100 Subject: [PATCH] fix(csv parse): only accept datetimes that aren't numbers (#2749) Co-authored-by: Henry Fontanier --- front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts b/front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts index c03e12a551d9..70c5a5384177 100644 --- a/front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts +++ b/front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts @@ -265,6 +265,8 @@ async function rowsFromCsv( // We keep the parsed values from the first parser that succeeds for all non-null values in the column. parsedValuesByCol[col] = (() => { for (const parser of [ + // number + (v: string) => (isNaN(parseFloat(v)) ? undefined : parseFloat(v)), // date/datetime (v: string) => { const date = new Date(v); @@ -276,8 +278,6 @@ async function rowsFromCsv( epoch, }; }, - // number - (v: string) => (isNaN(parseFloat(v)) ? undefined : parseFloat(v)), // bool (v: string) => { const lowerV = v.toLowerCase();