I have the comma separated data below in an HTML textarea element whose contents I store in a variable. Let that variable be called "output".
rowNum,column1,column2
1,1.450512e+005,1.982704e+00300
2,1.401080e+005,2.230725e+00300
3,1.351758e+005,2.643786e+00300
4,1.302602e+005,3.221424e+00300
5,1.253666e+005,3.962995e+00300
6,1.205006e+005,4.867671e+00300
7,1.156674e+005,5.934442e+00300
8,1.108727e+005,7.162115e+00300
9,1.061216e+005,8.549320e+00300
10,1.014195e+005,1.009451e+00400
11,9.677171e+004,1.179595e+00400
12,9.218335e+004,1.365175e+00400
13,8.765956e+004,1.565984e+00400
14,8.320540e+004,1.781796e+00400
15,7.882584e+004,2.012372e+00400
16,7.452578e+004,2.257453e+00400
I then do this:
data = d3.csvParse(output);
Based on this answer, I am using the Number() function to convert these scientific notation numbers to decimal numbers. While it works fine for the numbers in the first column, the second column does not get converted correctly.
For instance: Number(data[rowNum]["column1"])
ealuates correctly to 145051.2
for rowNum = 1
.
However, Number(data[rowNum]["column2"])
evaluates to 1.982704e+300
for rowNum = 1
.
And it's the same story for every subsequent row up to row 10.
Everything after row 10 evaluates to Infinity
.
Number(data[rowNum]["column2"])
evaluates to Infinity
for rowNum = 10
.
Why is this happening, and how can I prevent it?