-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[front] fix(csv) - csv parsing #9121
Conversation
front/lib/api/tables.ts
Outdated
for await (const anyRecord of parser) { | ||
if (i++ >= rowIndex) { | ||
const record = anyRecord as string[]; | ||
for (const [i, h] of header.entries()) { | ||
try { | ||
valuesByCol[h] ??= []; | ||
(valuesByCol[h] as string[]).push(record[i] || ""); | ||
(valuesByCol[h] as string[]).push(record[i] ?? ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What types of value are we going to get that we didn't get? Are they desirable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is preemptive and not related to the fix, here if we get a value of 0 in record[i]
it gets converted to ""
@@ -369,14 +369,14 @@ export async function rowsFromCsv({ | |||
|
|||
let i = 0; | |||
const parser = parse(csv, { delimiter }); | |||
const valuesByCol: Record<string, string[]> = {}; | |||
const valuesByCol: Record<string, string[]> = Object.create(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a bit more? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mb completely forgot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it was {}["constructor"]
that caused the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spolu added a comment in code to explain the Object.create(null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
values[h]
is a function: https://app.datadoghq.eu/logs?query=%40dd.env%3Aprod%20%22Error%20parsing%20record%22[…]=stream&from_ts=1733318910000&to_ts=1733318920000&live=falseonString
.null
andundefined
).> {}["constructor"] [Function: Object]
Tested with:
Risk
Low.
Deploy Plan