Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile action="read"

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
I have a textfile which I want to read only one column, and display that column next to the ID, is that possible?

I am using <CFFILE ACTION="read"> to read the file but it read ALL the records.

I would like somthing like:
Code:
[b]myFile.txt[/b]
[COLOR=red]ID   NAME   DESC[/color]
1   Bubba   My Places
2   Hubba   Your Places

I would like display on the #DESC#. How can I do that?


____________________________________
Just Imagine.
 
/sigh
why are you using cffile?
use cfhttp and output the first row like a query.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
BTW, I don't want to output the first row, only output the records for a specific column only.


____________________________________
Just Imagine.
 
Funny...
Just yesterday I was handed a small project where I use CFFTP and get a file from a remote server. Once the file is in our servers I have to read the first three columns specified in it.

I was going to use the Approach from the book "Advanced Coldfusion MX App. Development" by Forta. see Chapter 25 page 837. Reading a File line By Line. Here the author is using some java objects to open and read the file.
THe code can be found here [link]http://www.forta.com/books/0321127102/0321127102_25.zip[\link]
the listing is 25.3 and the name is JavaObjectLineNumberReader.cfm

As a second option I started playing around with this CFHTTP option that I never used or heard before, but due to authentication problems the only thing I get when trying to read the TXT file is just an error page.

It may worth a try, it seems an easy and fast way to get the contents of the txt file into a Query Object.

In any case try them both and see which one is better for your specific case. I like the Java approach since I can read a very long file without worrying of memory space.



grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
-----------------------------------------------
 
I actually wound up putting all recs in a dB, that was much easier then trying to use notepad. But I will play with this and see if I can get it work. In the very least, it may help someone else out.


____________________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top