Answered
How to loop through CSV file
Hi,
I want to loop through each column of a CSV file.
And while looping each column, I want to loop each row starting with the 2st row.
I wrote the code as below, but it is looping through the rows starting from row 1.
How do I make it start the loop as from row 2 in the CSV ?
(see code below)
Can someone tell me how to do this?
Thx
<!--- get and read the CSV-TXT file --->
<cffile action="read" file="C:\Documents and Settings\user\Desktop\EM-CSV\test.csv" variable="csvfile">
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<table border="1">
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
<!--- <cfoutput>#listgetAt('#index#',1, ',')#</cfoutput><br> --->
<tr>
<td><cfoutput>#index#</cfoutput></td>
<td><cfoutput>#listgetAt('#index#',2, ',')#</cfoutput></td>
<td><cfoutput>#listgetAt('#index#',3, ',')#</cfoutput></td>
</tr>
</cfloop>
</table>
I want to loop through each column of a CSV file.
And while looping each column, I want to loop each row starting with the 2st row.
I wrote the code as below, but it is looping through the rows starting from row 1.
How do I make it start the loop as from row 2 in the CSV ?
(see code below)
Can someone tell me how to do this?
Thx
<!--- get and read the CSV-TXT file --->
<cffile action="read" file="C:\Documents and Settings\user\Desktop\EM-CSV\test.csv" variable="csvfile">
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<table border="1">
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
<!--- <cfoutput>#listgetAt('#index#',1, ',')#</cfoutput><br> --->
<tr>
<td><cfoutput>#index#</cfoutput></td>
<td><cfoutput>#listgetAt('#index#',2, ',')#</cfoutput></td>
<td><cfoutput>#listgetAt('#index#',3, ',')#</cfoutput></td>
</tr>
</cfloop>
</table>
