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

PHP: Numbers that are a string #9

Open
ursbraem opened this issue Sep 26, 2012 · 6 comments
Open

PHP: Numbers that are a string #9

ursbraem opened this issue Sep 26, 2012 · 6 comments

Comments

@ursbraem
Copy link

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?

@mbbender
Copy link

Same issue here.

@Abromeit
Copy link

[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.

@thdoan
Copy link

thdoan commented Nov 24, 2014

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.

@victor-t
Copy link

victor-t commented Jan 25, 2017

@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.

@thdoan
Copy link

thdoan commented Feb 8, 2017

@victor-t I fixed this long back, along with a few other enhancements in my fork.

@victor-t
Copy link

victor-t commented Feb 8, 2017

@thdoan I figured but just incase ;) i'll take a look at your fork cause i just recently started using this.

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

No branches or pull requests

5 participants