Skip to content
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

wrong parsing d3.tsvParse with only number header #77

Closed
samuelvaneck opened this issue Aug 19, 2020 · 4 comments
Closed

wrong parsing d3.tsvParse with only number header #77

samuelvaneck opened this issue Aug 19, 2020 · 4 comments

Comments

@samuelvaneck
Copy link

samuelvaneck commented Aug 19, 2020

I have an issue with headers that contain only numbers. It's not being parsed correctly by d3.tsvParse. The header with the number has the values of the first column.

The problem is with the last column 1234

E.g.
data string:
Distance_from_anode[nm] TAPC mCBP 4CzIPN-Me T2T 1234
70 0 0 0 0 0.000304539
71 0 0 0 0 0.000234767
72 0 0 0 0 0.00016237

is returns following incorrect result
index 70
4CzIPN-Me: 1e-99
1234: 70
Distance_from_anode[nm]: 1e-99
T2T: 0.000304539
TAPC: 1e-99
mCBP: 1e-99

index 71
4CzIPN-Me: 1e-99
1234: 71
Distance_from_anode[nm]: 1e-99
T2T: 0.000234767
TAPC: 1e-99
mCBP: 1e-99

index 72
4CzIPN-Me: 1e-99
1234: 72
Distance_from_anode[nm]: 1e-99
T2T: 0.00016237
TAPC: 1e-99
mCBP: 1e-99

Expected
index 70
4CzIPN-Me: 1e-99
1234: 0.000304539
Distance_from_anode[nm]: 70
T2T: 1e-99
TAPC: 1e-99
mCBP: 1e-99

index 71
4CzIPN-Me: 1e-99
1234: 0.000234767
Distance_from_anode[nm]: 71
T2T: 1e-99
TAPC: 1e-99
mCBP: 1e-99

index 72
4CzIPN-Me: 1e-99
1234: 0.00016237
Distance_from_anode[nm]: 72
T2T: 1e-99
TAPC: 1e-99
mCBP: 1e-99

I'm fixing if for now to check if the header has only number and adding an underscore in that's true.

@samuelvaneck samuelvaneck changed the title wrong parsing d3.tsvParse wrong parsing d3.tsvParse with only number header Aug 19, 2020
@Fil
Copy link
Member

Fil commented Aug 19, 2020

Sorry I can't reproduce the issue: https://observablehq.com/d/f47916b62d483682

Fil added a commit that referenced this issue Aug 19, 2020
@samuelvaneck
Copy link
Author

I tried again. It fails the code in my local dev enviroment but success on the observerablehq.com website. Not sure why for now. I'll futher investigate the issue.

Fil added a commit that referenced this issue Aug 23, 2020
@stahlmanDesign
Copy link

It could be related to the fact that you can't use dot notation if an object key begins with a number:

const invalidObj = { 1234: 0.000304539 } // error, 1234 cannot be the key unless cast as a string

const validObj = { '1234': 0.000304539 } // Valid, but can't access with dot notation
console.log(validObj.1234) // error
console.log(validObj['1234']) // 0.000304539 // must access the value using brackets

const alsoValid = { '1234 this phrase with spaces can also be an object key': 0.000304539 } // another example

@mbostock
Copy link
Member

Closing since we can’t reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants