benwinding / react-admin-import-csv

A csv file import button for react-admin
https://benwinding.github.io/react-admin-import-csv
MIT License
135 stars 46 forks source link

[Howto] Specific type (boolean, etc.) #16

Closed kei-ix closed 4 years ago

kei-ix commented 4 years ago

Hi,

Nice work!! You saved me time! I'm new in React and I'm working on a side project to develop a small admin interface above my own API.

I have a small question: is it possible to import via CSV specific type, like boolean ?

Thank you !

VicenteVicente commented 4 years ago

Hi!, you could use the papaparse's parseConfig dynamicTyping: true. It parses numbers and booleans automaticly. For example:

const config = {
    parseConfig: {
      dynamicTyping: true,
  }

and then:

<ImportButton {...config} />

kei-ix commented 4 years ago

I checked on Papaparse's documentation, according to your comment and I found the solution: dynamicTyping: true 🥳

Thank you very much for your help !