lib/Map/TableStructure.js
function castToScalar(value, state) {
    if (state.rowNum === 1) {
      // Don't cast column names
      return value;
    } else {
      var hasDot = /\./;
      var leadingZero = /^0[0-9]/;
      var numberWithThousands = /^[1-9]\d?\d?(,\d\d\d)+(\.\d+)?$/;
      if (numberWithThousands.test(value)) {
        value = value.replace(/,/g, "");
      }
      if (isNaN(value)) {
        return value;
      }
      if (leadingZero.test(value)) {
        return value;
      }
      if (hasDot.test(value)) {
        return parseFloat(value);
      }
      var integer = parseInt(value, 10);
      if (isNaN(integer)) {
        return null;
      }
      return integer;
    }
  }
function castToScalar(value, state) {
    if (state.rowNum === 1) {
      // Don't cast column names
      return value;
    } else {
      var hasDot = /\./;
      var leadingZero = /^0[0-9]/;
      var numberWithThousands = /^[1-9]\d?\d?(,\d\d\d)+(\.\d+)?$/;
      if (numberWithThousands.test(value)) {
        value = value.replace(/,/g, "");
      }
      if (isNaN(value)) {
        return value;
      }
      if (leadingZero.test(value)) {
        return value;
      }
      if (hasDot.test(value)) {
        return parseFloat(value);
      }
      var integer = parseInt(value, 10);
      if (isNaN(integer)) {
        return null;
      }
      return integer;
    }
  }
function castToScalar ( value , state ) { if ( state . rowNum === 1 ) { // Don't cast column names return value ; } else { var hasDot = / \. / ; var leadingZero = / ^0[0-9] / ; var numberWithThousands = / ^[1-9]\d?\d?(,\d\d\d)+(\.\d+)?$ / ; if ( numberWithThousands . test ( value ) ) { value = value . replace ( / , / g , "" ) ; } if ( isNaN ( value ) ) { return value ; } if ( leadingZero . test ( value ) ) { return value ; } if ( hasDot . test ( value ) ) { return parseFloat ( value ) ; } var integer = parseInt ( value , 10 ) ; if ( isNaN ( integer ) ) { return null ; } return integer ; } }
Originally from jquery-csv plugin. Modified to avoid stripping leading zeros.
Originally from jquery - csv plugin . Modified to avoid stripping leading zeros .