Without seeing the code, it’s difficult to advise.
Have you tried converting the values to a string and then to a number? value.toString() should expand the exponentiation to a raw number (string), and then converting to a number using parseInt() or parseFloat() might fix this.
Without seeing the code, it’s difficult to advise.
Have you tried converting the values to a string and then to a number? value.toString() should expand the exponentiation to a raw number (string), and then converting to a number using parseInt() or parseFloat() might fix this.
Yes, I have. When I try to stringify the input, it just changes the already formatted scientific notation numbers into a string. Unfortunately, the automatic parsing in the script block seems to run prior to me being able to run any code in the same script. It seems that as soon as you do the input.fileAsync function and upload the file, the automatic parsing happens as part of the upload process, turning my field with long numbers, into a number field and formatting it as scientific notation that I can’t translate back to a string of numbers.
Yes, I have. When I try to stringify the input, it just changes the already formatted scientific notation numbers into a string. Unfortunately, the automatic parsing in the script block seems to run prior to me being able to run any code in the same script. It seems that as soon as you do the input.fileAsync function and upload the file, the automatic parsing happens as part of the upload process, turning my field with long numbers, into a number field and formatting it as scientific notation that I can’t translate back to a string of numbers.
I cannot imagine a case where this is impossible to overcome. Share some code and let the experts take a look.
Yes, I have. When I try to stringify the input, it just changes the already formatted scientific notation numbers into a string. Unfortunately, the automatic parsing in the script block seems to run prior to me being able to run any code in the same script. It seems that as soon as you do the input.fileAsync function and upload the file, the automatic parsing happens as part of the upload process, turning my field with long numbers, into a number field and formatting it as scientific notation that I can’t translate back to a string of numbers.
Hi @Sam_Cederwall,
I believe this is an artifact of the file parser seeing a number, and representing it as such. In JavaScript, if a number is longer than 21 digits, JS will use exponential notation to represent it. Somewhat relatedly, the Number.MAX_SAFE_INTEGER
in JavaScript is +/- 9007199254740991 - for numbers greater than / less than this, you’ll see JavaScript start rounding things. You can test this yourself in your browser console with the following snippet:
const foo = 12345678901234567890;
console.log(foo); // not the same digits
Getting back to your issue, there’s not currently any way to opt-out of the auto-parsing with fileAsync
, but it sounds like this could be a useful feature to add - I’ll log a request. I envision this as a useRawValues
or similar option, which causes parsedContent
to return just the raw string values for all cells in the CSV (e.g. no date parsing, no number parsing, etc.).
As a temporary workaround for the near term, you could “trick” the parser into thinking the value is a string prefixing another character (e.g. “num1234567890…”), then stripping it out of the parsedContents
result, leaving you with just the string representation of the number.
Hi @Sam_Cederwall,
I believe this is an artifact of the file parser seeing a number, and representing it as such. In JavaScript, if a number is longer than 21 digits, JS will use exponential notation to represent it. Somewhat relatedly, the Number.MAX_SAFE_INTEGER
in JavaScript is +/- 9007199254740991 - for numbers greater than / less than this, you’ll see JavaScript start rounding things. You can test this yourself in your browser console with the following snippet:
const foo = 12345678901234567890;
console.log(foo); // not the same digits
Getting back to your issue, there’s not currently any way to opt-out of the auto-parsing with fileAsync
, but it sounds like this could be a useful feature to add - I’ll log a request. I envision this as a useRawValues
or similar option, which causes parsedContent
to return just the raw string values for all cells in the CSV (e.g. no date parsing, no number parsing, etc.).
As a temporary workaround for the near term, you could “trick” the parser into thinking the value is a string prefixing another character (e.g. “num1234567890…”), then stripping it out of the parsedContents
result, leaving you with just the string representation of the number.
Thanks Billy, I think that will definitely work as a temporary workaround.
While the parser is super useful for a lot of cases, having the useRawValues would be super helpful for cases like this and I’m sure has applications that extend beyond just large numbers.
Thank you for all the help, much appreciated.