By 05/02/2014 1 Comments

How to Converting CSV into Javascript array

What is CSV ?

  • It stands for comma separated values
  • These are different multiple values with comma separation (e.g php, javascript, asp, facebook etc)
  • It is also called CSV file, that means that file’s extension is .csv and it contains comma separated values or data

str.split() method / function

  • This function split a string,┬áseparated by any token into a Javascript array
  • Always return an new array
  • split() function belongs with string class

Following code describes the conversion of a CSV values into an array. For this you will use the split() method.

<script>

var str = "a, b, c, d"; // string CSV(comma separated values) to be converted, assign in to str variable

var arr = str.split(","); // call split() method by str followed by .dot, pass 1 parameter (comma ,) and assign into an array arr

// Output arr[0]: a

</script>






Posted in: JavaScript

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .