PHP: Numbers that are a string
ursbraem opened this issue · 6 comments
Hi!
First let me say that Mr. Data Converter is super awesome. Thanks a lot!
I've had an issue when pasting the following code from Excel:
Tag/e Monat/e Jahr Veranstaltung Organisator Referatstitel Ort
14-15 8 2007 Event Stadt Zürich Title Zürich
The first value is a string. But it looks like a calculation. What Mr. D gives back is:
array("val0"=>14-15,"val1"=>8,"val2"=>2007,"val3"=>"Zürcher Ferienpass","val4"=>"Stadt Zürich","val5"=>"Dein Handy und die Technik","val6"=>"Zürich"),
And what PHP gives back for $row['val0'] is: -1
because it does the math for 14-15.
Would it therefore make sense to be able to add double quotes around each value, also numeric ones?
Same issue here.
[Update] Current situation in the Demo:
- Numbers that contain special chars like '.' or '-' are quoted, simple numbers are not.
Just like @ursbraem, I believe that it's way better to quote everything.
But anyway...might be OK to close this issue if you like to.
There is another scenario to consider: postal codes. For example, I'm converting a sheet with a postal code column that contains the value "0800" (a postal code in Australia). The converted JSON property is "postcode":0800, which is invalid. Please provide an option to quote all values, even when the string is all numbers.
@thdoan In my situation, UPC code starts with zeros some times. I forked a copy and commented out a few lines.
in js/CSVParser.js
//---------------------------------------
// UTILS
//---------------------------------------
isNumber: function(string) {
// if( (string == null) || isNaN( new Number(string) ) ) {
return false;
},
// return true;
// },
You could probably deleted the whole thing but basically it returns false all the time so it never tries to parser into numbers/int
I would add an option to turn this off and on though. But this was a quick and easy way to change the tool to get the same results.