nzambello / react-csv-reader

React component that handles csv file input and its parsing
https://nzambello.github.io/react-csv-reader/
MIT License
199 stars 48 forks source link

Casting fields as number #36

Closed caio-davi closed 4 years ago

caio-davi commented 4 years ago

Hi,

All the fields are being cast. So, values like '02310' are imported as '2310'. I'm not sure if this is the desired behavior, but I need to keep the original value. Is there a way to do this?

Thank you,

nzambello commented 4 years ago

Hi, yes, there is! This isn't my component's fault, it's PapaParse configuration stuff, as explained here.

In my example in the README the config object uses:

{
  ...
  dynamicTyping: true,
}

and this make PapaParse to convert strings if the value can be a number or something else (I guess). See docs here.

So, if you're not using that configuration attribute, you should be fine, having only strings as they are.

Tell me if this helps you.

caio-davi commented 4 years ago

Yes, my problem is solved!

Thank you very much!