How to read data From *.CSV file using javascript?

后端 未结 13 787
不知归路
不知归路 2020-11-22 00:46

My csv data looks like this:

heading1,heading2,heading3,heading4,heading5,value1_1,value2_1,value3_1,value4_1,value5_1,value1_2,value2_2,value3_2,val

13条回答
  •  执念已碎
    2020-11-22 01:10

    I am using d3.js for parsing csv file. Very easy to use. Here is the docs.

    Steps:

    • npm install d3-request

    Using Es6;

    import { csv } from 'd3-request';
    import url from 'path/to/data.csv';
    
    csv(url, function(err, data) {
     console.log(data);
    })
    

    Please see docs for more.

    Update - d3-request is deprecated. you can use d3-fetch

提交回复
热议问题