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

后端 未结 13 784
不知归路
不知归路 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:30

    Per the accepted answer,

    I got this to work by changing the 1 to a 0 here:

    for (var i=1; i<allTextLines.length; i++) {
    

    changed to

    for (var i=0; i<allTextLines.length; i++) {
    

    It will compute the a file with one continuous line as having an allTextLines.length of 1. So if the loop starts at 1 and runs as long as it's less than 1, it never runs. Hence the blank alert box.

    0 讨论(0)
提交回复
热议问题