Skip to content

Commit

Permalink
fix(csv parse): be stricter with float parsing (#2987)
Browse files Browse the repository at this point in the history
* fix(csv parse): be stricter with float parsing

* allow negative numbers

---------

Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Dec 21, 2023
1 parent 4b59e8c commit 215c7c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 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 @@ -303,10 +303,11 @@ async function rowsFromCsv(
parsedValuesByCol[col] = (() => {
for (const parser of [
// number
(v: string) => (isNaN(parseFloat(v)) ? undefined : parseFloat(v)),
(v: string) =>
/^-?\d+(\.\d+)?$/.test(v.trim()) ? parseFloat(v.trim()) : undefined,
// date/datetime
(v: string) => {
const date = new Date(v);
const date = new Date(v.trim());
const epoch = date.getTime();
return isNaN(epoch)
? undefined
Expand Down

0 comments on commit 215c7c9

Please sign in to comment.