Code
1 | <!DOCTYPE html> |
Note that "\n" is needed at the end of each line to indicate the end of a row of data in the CSV string; without it, the whole CSV string will be treated as one line and you will have one long row of data...
Once the code is done, save it as index.html (or other filename name that ends with ".html"), then double click on the saved file to launch a browser to execute it.
Result
At first glance, there's nothing to see.
If Google Chrome is used, enable the Developer Tools under More Tools / Developer Tool.
Under Console, there is an array that contains 10 rows of data.
Click on data, then on individual Array to see the data.
The CSV string is now successfully parsed and put in an array.
References:
Parsing a Local CSV File with JavaScript and Papa Parse
http://www.joyofdata.de/blog/parsing-local-csv-file-with-javascript-papa-parse/
How to Create Website Graphs from CSV Files with c3.js and PapaParse
https://youtu.be/1OK4TJfCzdY
Comments
Post a Comment