Copy link to clipboard
Copied
I need to exclude the column names which are the first row of the file...Currently, I am not able...Any help appreciated..
EID Score
-----------
e1 100
e2 200
:::code:::
<cffile action="read" file="#CurrDir#SC_Flat.csv" variable="csvfile">
<!---cfdump var="#csvfile#"--->
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
<cfoutput>#listgetAt('#index+1#',1, ',')#<br /></cfoutput>
</cfloop>
Copy link to clipboard
Copied
ListRest() should work.
Copy link to clipboard
Copied
OR a simple counter in your loop to exclued the first line or two or three from being inserted into your database.
<cfset counter = 1>
<cfloop ....>
<cfif counter GT 3>
<cfoutptut>...</cfoutput>
</cfif>
<cfset counter = counter + 1>
</cfloop>
Copy link to clipboard
Copied
Thank you guyzzz
Copy link to clipboard
Copied
Hope this idea isn't too late for you...
You could setup a CSV ODBC datasource, and then connect to that in the datasources part.
You'll have to tell it the separators, but you can easily setup a datasource per type to make it easier.
As long as you know the folder that the files will be located, you can run the query like this:
<cfquery name="CSV_data" datasource="CSV_test">
select *
from test.csv
</cfquery>
It should be easier on the memory than trying to treat it as a list, and faster too for larger files.
Copy link to clipboard
Copied
Thank u. I am not using cfchart ...anymore
Copy link to clipboard
Copied
* confused look *
Copy link to clipboard
Copied
Sorry... I mean Thank you all for support and advice..
Copy link to clipboard
Copied
I realised afterwards that you had another thread about cfchart, so you might have confused the threads and posted on the wrong one - just seemed a little strange that you was talking about cfchart on a CSV question
Copy link to clipboard
Copied
Yes i know... was so busy doing lots of things