Need help with csv read.
I have some csv files that are in this format:
"Source","Requester ID","ID","Start Date","End Date","location","Value","TimeStamp"
"DCA","tedkrasav","9913457","12/4/2016 12:00:00 AM","12/18/2016 12:00:00 AM","Room_121",,"12/3/2016 2:50:03 PM"
What I am trying to do is read the file and insert all of the individual columns into a DB table.
I am trying to do this method just to see the individual columns but I keep getting an error that states "Invalid list index 2.In function ListGetAt(list, index [, delimiters]), the value of index, 2, is not a valid as the first argument (this list has 1 elements). Valid indexes are in the range 1 through the number of elements in the list" :
<cffile action="read" file="csvdemo.csv" variable="csvfile">
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
<cfoutput>
#listgetAt('#index#',1, ',')# #listgetAt('#index#',2, ',')# #listgetAt('#index#',3, ',')# #listgetAt('#index#',4, ',')#
</cfoutput>
</cfloop>
Does anyone know what I am doing wrong?
