Skip to content

Commit

Permalink
fix(csv parse): only accept datetimes that aren't numbers (#2749)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Dec 1, 2023
1 parent e4d8a66 commit 5fa3aa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions front/pages/api/w/[wId]/data_sources/[name]/databases/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -276,8 +278,6 @@ async function rowsFromCsv(
epoch,
};
},
// number
(v: string) => (isNaN(parseFloat(v)) ? undefined : parseFloat(v)),
// bool
(v: string) => {
const lowerV = v.toLowerCase();
Expand Down

0 comments on commit 5fa3aa3

Please sign in to comment.