Kay,

You could try this (written in psudo-code)

1 replace "," with ||
2 loop through items using , as delimiter
3 set || back to ","

This would remove the problem with the multiple commas and seems to be a
relatively easy solution.  You should only have to add two lines of code (#1
and #3).

Hope this helps (and works :),
Reuben Poon


-----Original Message-----
From: Kay Smoljak [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 12, 2002 9:52 AM
To: CF-Talk
Subject: list delimiters
Importance: Low


I'm trying to import a CSV, do some fiddling with it, then save it off
as a file again. Some of the fields contain commas within them, so these
fields are all enclosed in double quotes. I am reading in the file like
this:

<cffile action="read" file="c:\inetpub\wwwroot\test.csv"
variable="origCSV">
<cfset temp = StructNew()>

then looping over it like this:

<cfset counter = 0>
<cfloop list="#origCSV#" index="w" delimiters="#chr(10)##chr(13)#">
        <cfset counter = counter + 1>
        <cfset temp[counter] = StructNew()>
        <cfset temp[counter].raw = w>
        <cfset counter2 = 0>
                <cfloop list="id,title,blurb,ReleaseDate" index="q">
                        <cfset counter2 = counter2 + 1>
                        <cfset temp[counter][q] =
ListGetAt(temp[counter].raw,counter2,",")>
                </cfloop>
</cfloop>

Which is fine, except it's not taking into account commas that appear in
the title or blurb fields. I'm sure there's a simple answer, but I'm at
a loss to see it. Any ideas?

Thanks heaps,
Kay.
______________________________________
Kay Smoljak              Web Developer
Custom Tags: developer.perthweb.com.au


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to