csv 转 json
Github https://github.com/mholt/PapaParse
Npm https://www.npmjs.com/package/papaparse
网站 https://www.papaparse.com

  1. // pnpm add papaparse
  2. // Parse CSV string
  3. const data = Papa.parse(csvString, config);
  4. // Convert back to CSV
  5. const csv = Papa.unparse(data);
  6. // Parse local CSV file
  7. Papa.parse(file, {
  8. complete: function(results) {
  9. console.log("Finished:", results.data);
  10. }
  11. });
  12. // Stream big file in worker thread
  13. Papa.parse(bigFile, {
  14. worker: true,
  15. step: function(results) {
  16. console.log("Row:", results.data);
  17. }
  18. });

在线案例
https://www.papaparse.com/demo
image.png

d3-dsv

https://github.com/d3/d3-dsv
csv转 d3 json