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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping thru a CSV

Status
Not open for further replies.

MarcDePoe

Programmer
Dec 19, 2000
101
US
I need to display the first 10 records of a comma delimited file.

Currently, I loop through it #CHR(13)##CHR(10)# delimited.
Inside that loop ',' delimited.

I know coldfusion treats ',,' as one record, so I replace all ',,' with ', ,' as place-holders for blank records and that works fine.

The problem is when a field contains linebreaks ...
My loop is fooled at first sight of these buggers and thinks it's a new record.

How on earth am I supposed to differentiate the linebreaks?!

I never have trouble loading such files into MySql for instance, so I know there is something I have not thought of.

big time stumped
- Marc
 
Hey MarcDePoe,

Sounds like a "catch 22" with your delimiter and your newline. What I would do is change the delimiter "#CHR(13)##CHR(10)#" with something else, if that is possible.

If you can't change the delimiter what about checking the characters in the text before they are entered into the CSV to make sure that doesn't happen you can replace &quot;#CHR(13)##CHR(10)#&quot; with &quot;<br>&quot;.

Hope it helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top