> something similar on the net, but I don't know how to incorporate a while
> statement in my code as below:
The code should look like this:
<cfset CRLF = Chr(13) & Chr(10)><!--- Linefeed & carriage return --->
<cffile action="" file="#ExpandPath('/pharma/uploads')#/Book1.csv"
variable="csvData">
<cfset csvData = Replace(csvData, ",,", ", ,", "ALL") >
<cfloop index="csvRecord" list="#csvData#" delimiters="#CRLF#">
<cfset csvArray = ArrayNew(1)>
<cfset csvCellCount = 1>
<cfloop index="csvCell" list="#csvRecord#" delimiters=",">
<cfset csvArray[variables.csvCellCount] = Trim(csvCell)>
<cfset csvCellCount = csvCellCount + 1>
</cfloop>
<cfdump var="#csvArray#">
</cfloop>
Empty list elements are replaced with elements with a space in them before the loop
begins. And inside the loop you need to Trim the cell content before putting it into
the array (you could make a <cfif csvCell eq ' '>cell is empty<cfelse><cfset
csvArray[variables.csvCellCount] = csvCell> if you care about spaces at the start
and end of a cell content).
--
<mack />
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

