I was parsing through a csv file today and having issues with empty values. The data I'm receiving is in a format the 3rd party cannot update, so my data looked something like this
1,,abc,32,,gef
Dumping the list provides the expected list, but looping through the list it skips over values
2 <cfloop list="#list1#" index="i">
3 #i#<br>
4 </cfloop>
5</cfoutput>
produces
2abc
332
4gef
After googling this for a bit I gave up and asked my brother. He told me to use the 'includeemptyfields' attribute in listtoarray(). I knew I could turn a list into an array, but I wasn't aware of the third attribute until today, the default is obviously false, so blank values were never included.
The code below produces the desired output. Notice I am now looping through an array instead of a list.
2<cfoutput>
3 <cfloop array="#newlist#" index="i">
4 #i#<br>
5 </cfloop>
6</cfoutput>
7
81
9
10abc
1132
12
13gef
#1 by James Moberg on 12/4/12 - 12:24 PM
I encountered difficulty with ColdFusion when a valid CSV file had carriage returns and inconsistent columns. I was able to process the data by adding the OpenCSV java library to the server and then looping over the array:
http://www.stephenwithington.com/blog/index.cfm/20...
NOTE: I couldn't get this blog page to open using Safari on the iPhone. It displayed the jQuery Mobile navigation, but clicking on the link didn't do anything.