Skip to main content
November 7, 2013
Answered

How to query a csv file

  • November 7, 2013
  • 2 replies
  • 1619 views

Hello I am new to cold fusion.

I am wondering if there is a way to query a csv file using a read from cffile? Currently I have it setup as a cffile read and then I try to query the file using cffquery. Obviously this doesn't work because I have to set a datasource. Is there anyway to do this or any way to set a csv file as a data source? Any help or direction would be greatly appreciated.

Thanks.

This topic has been closed for replies.
Correct answer Steve Sommers

You would have to read in the csv and create a query using QueryNew(). Once you have the csv in a query format, then you can perform query of queries to do most anything you want on the data. There is probably code already written out there to do the csv to query, you just need to find it. The query of queries is in the documentation. The only gotcha is that query of queries sorting and matching is case sensitive. Hope this helps.

2 replies

Participating Frequently
November 8, 2013

This article shows how to query a CSV file: http://www.coldfusionmuse.com/index.cfm/2007/2/5/csv

Also make sure and read all the comments beneath it

November 8, 2013

Hey thanks for the help I actually saw this article before I posted here. The datasource stuff was a little over my head and I was in a time crunch to get it done. I didnt have time to rerch all the extra stuff.

Thanks again.

Steve SommersCorrect answer
Legend
November 7, 2013

You would have to read in the csv and create a query using QueryNew(). Once you have the csv in a query format, then you can perform query of queries to do most anything you want on the data. There is probably code already written out there to do the csv to query, you just need to find it. The query of queries is in the documentation. The only gotcha is that query of queries sorting and matching is case sensitive. Hope this helps.

November 8, 2013

I really appreciate your advice and reply. This was the easiest way for me to get this done. Thanks for keeping it simple and sending me in the right direction.