listGetAt() - What am I doing wrong??
Maybe I just don't see it, but I can;t seem to get this to work.
- I'm trying to parse through a giant CSV file from mailchimp, just grabbing a couple of bits of data from each line.
- I'm treating the file as a list of lists, 1 list per line.
- for some reason the list index does not work, i.e. listgetat(list, 1, ',') works, but, listgetat(list,2,',') gives me an invalid index error
BUT
I can loop over the list using a <cfloop> tag with no index errors!!??!!
See example:
// get rid of header line
<cfset variables.csvContent = listDeleteAt(variables.csvContent, 1, ']') />
// remove the line qualifiers & replace with a line feed
<cfset variables.csvContent = replace(variables.csvContent, '[', '', 'all') />
<cfset variables.csvContent = replace(variables.csvContent, ']', '#Chr(13)#', 'all') />
// loop over the main list using the line feed as a delimiter
<cfloop list="#variables.csvContent#" delimiters="#Chr(13)#" index="i">
// this works, it shows each row with the correct number of elements (12)
#i# - #listlen(i,',')#
// here is a sample row:
//"email@domain.com","fname","lname","company","group","uid",2,"",null,"date","IP","date"
// this DOES work, I get the first element [an email addy]
#listGetAt(i,1,',')#
// this does not work, I get an invalid index error
#listGetAt(i,2,',')#
// this DOES work, I get each of the 12 list elements returned.
<cfloop list="#i#" delimiters="," index="j" >
#j#
</cfloop>
I just don't see what I am doing wrong here.....
-help!
