• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CSV File Reading Help

Participant ,
Sep 29, 2009 Sep 29, 2009

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>

TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2009 Sep 29, 2009

Copy link to clipboard

Copied

ListRest() should work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 29, 2009 Sep 29, 2009

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 29, 2009 Sep 29, 2009

Copy link to clipboard

Copied

Thank you guyzzz

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 30, 2009 Sep 30, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 30, 2009 Sep 30, 2009

Copy link to clipboard

Copied

Thank u. I am not using cfchart ...anymore

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 01, 2009 Oct 01, 2009

Copy link to clipboard

Copied

* confused look *

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 01, 2009 Oct 01, 2009

Copy link to clipboard

Copied

Sorry... I mean Thank you all for support and advice..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 01, 2009 Oct 01, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 01, 2009 Oct 01, 2009

Copy link to clipboard

Copied

LATEST

Yes i know... was so busy doing lots of things 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation