0

im new to js, have two question about how to parse a csv, i have a simple csv with two column, column1:'user', column2:'amount'

  1. how can i get one array with all the 'user' column value and one array with all the 'amount' column value?

  2. And can i loop trough the rows and use index to get the value of the two column? something like csv['amount'][0] or csv[0][1] or something like this?

ty.

Amnesia420
  • 15
  • 4

1 Answers1

1

First, declare 2 arrays, one for user, one for amount.

And then read this post to know how to read a file line by line.

After that, read this post to know how to split a string with a comma separator.

Finally, use the array.push() method to push the data into an array.

The KNVB
  • 3,588
  • 3
  • 29
  • 54