Skip to content
Advertisement

How to upload and read CSV files in React.js?

I would like the user to upload a .csv file, and then have the browser be able to parse the data from that file. I am using ReactJS. How would this work? Thanks.

Advertisement

Answer

Figured it out. A combination of react-file-reader and HTML5’s FileReader (see this page).

Placed the react-file-reader bit inside of render:

JavaScript

And then this above.

JavaScript
Advertisement