cancel
Showing results for 
Search instead for 
Did you mean: 

CSV converting number to scientific notation

silvad33
New Contributor

Hi,

I am reading the following item sku’s from a .csv file:

301936586218
301937308505
301937314218
301937818011

unfortunately .csv converts these values to scientific notation resulting in them all being read as 3.02E+11

Is there a way within snaplogic to convert these back to their original values?

Thank you,

Daniel

3 REPLIES 3

cjhoward18
Employee
Employee

Hi @silvad33

It seems that the number in scientific notation has lost some degree of its precision from the original value that I am not sure how you could possibly get back.

In a Mapper Snap, the expression parseInt(3.02E+11) will give you the value: 302000000000 getting rid of the scientific notation, but not the exact original value since the precision is gone in the scientific notation representation of the number.

ptaylor
Employee
Employee

Are you saying that the CSV Parser snap is what seems to be converting them? The .csv file itself has the full original values, correct?

It looks like CSV Parser handles it fine if the .csv file actually contains those values. But my guess is that you’re opening the file with Excel, which by default converts all of those to scientific notation, then saving it from Excel, which overwrites the .csv file. Right? My advice would be to create a new Excel document, import the CSV into it, which lets you select the format of each column it imports. Select Text format for the SKU column on the import so it doesn’t interpret those values as numbers. When you’ve done your editing, just export the data back to a csv file.

Or… don’t save in Excel if you’re just trying to open the .csv file to look at it but not change it.