array as a result of your code. You overwrite it for every record. Maybe
you want a 2-dimensional array?
Your code corrected:
<cfsript>
csvRecord = Replace(csvRecord,",,",", ,","all");
csvArray = ListToArray(csvRecord);
</cfscript>
This will give you a space for empty records. If this is not acceptable,
you will need a second loop:
<cfset csvRecord = Replace(csvRecord,",,",", ,","all")>
<cfset csvArray = ArrayNew(1)>
<cfloop index="csvCell" list="#csvRecord#">
<cfset ArrayAppend(csvArray,Trim(csvCell))>
</cfloop>
Pascal
> -----Original Message-----
> From: Brant Winter [mailto:[EMAIL PROTECTED]
> Sent: 01 September 2004 11:41
> To: CF-Talk
> Subject: cfloop over csv not working with empty fields
>
> Hi - just wondering how to go about looping over a list generated from
a
> csv
> file that has empty fields, ie, 1,2,3,4,,6,7
>
>
>
> My code is as follows:
>
>
>
> <cfset CRLF = Chr(13) & Chr(10)><!--- Linefeed & carriage return --->
>
> <cffile action="" file="#ExpandPath('/pharma/uploads')#/Book1.csv"
> variable="csvData">
>
>
>
> <cfloop index="csvRecord" list="#csvData#" delimiters="#CRLF#">
>
>
>
> <cfset csvArray = ArrayNew(1)>
>
> <cfset csvCellCount = 1>
>
>
>
> <cfloop index="csvCell" list="#csvRecord#" delimiters=",">
>
> <cfset csvArray[variables.csvCellCount] =
csvCell>
>
> <cfset csvCellCount = csvCellCount + 1>
>
> </cfloop>
>
>
>
> <cfdump var="#csvArray#">
>
> </cfloop>
>
>
>
> It produces arrays that do not include an empty field for a csv cell
that
> is
> empty. I have tried to include cfif statements to changes the output
of
> the
> csvCell variables if it is empty, but I am having no luck. Please help
!
>
>
>
> ----------------------------------------------------------------
> The information transmitted is intended only for the person or entity
to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of,
or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you
received
> this in error, please contact the sender and delete the material from
any
> computer. It is the responsibility of the recipient to ensure that the
> onward transmission, opening or use of this message and any
attachments
> will not adversely affect its systems or data. Please carry out such
virus
> and other checks, as you consider appropriate. To the fullest extent
> allowed by law, no responsibility is accepted by Haematology &
Oncology
> Clinics of Australasia for any virus damage caused by this message.
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

