Page 1 of 1

Parse CSV: Ignore First Line

Posted: September 8th, 2010, 1:17 pm
by sbaden
I have a script that prompts the user to select a CSV file. The script then parses the CSV into a table. I'm not sure how to tell it to ignore the first line of the table. Here is the script:

Code: Select all

var table = new Array();
var lines = encoded_data.split(/\r*\n/);
	
for (i = 0; i < lines.length; i++) {
     table[i] = lines[i].split(",");
}

Re: Parse CSV: Ignore First Line

Posted: September 8th, 2010, 2:30 pm
by Dan Ebberts
Try this (not tested):

Code: Select all

for (i = 1; i < lines.length; i++) {
     table[i-1] = lines[i].split(",");
}

Dan

Re: Parse CSV: Ignore First Line

Posted: September 8th, 2010, 4:14 pm
by sbaden
Worked great Dan. Thank you... :D