|
|
Home / Groups / ColdFusion Newbie (CF-Newbie)
writing file, csv or xls?Hi, I am wondering what I would have to do to change this to work with a .xls file compare to now using a csv file? I tried to change the csv variables to xls, as well as the name of the file from .csv to .xls, but I guess there are differences between the two formats. When I try that I get the error: Thanks so much, John Error Code 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. The error occurred in /Users/johnbarrett/Sites/GotNutrients/adminNew/upload/write_file_xls.cfm: line 57 55 : VALUES 56 : ('#listgetAt('#index#',1, ',')#', 57 : '#listgetAt('#index#',2, ',')#', 58 : '#listgetAt('#index#',3, ',')#', 59 : '#listgetAt('#index#',4, ',')#', The write file code <!--- get and read the CSV-TXT file ---> <cffile action="read" file="myfolder/csvdemo.csv" variable="csvfile"> <!--- loop through the CSV-TXT file on line breaks and insert into database ---> <cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#"> <cfquery name="importcsv" datasource="#REQUEST.dataSource#"> INSERT INTO datefield2(tiptopic,dailytip,tipdate,consumer_link,research_link) VALUES ('#listgetAt('#index#',1, ',')#', '#listgetAt('#index#',2, ',')#', '#listgetAt('#index#',3, ',')#', '#listgetAt('#index#',4, ',')#', '#listgetAt('#index#',5)#' ) </cfquery> </cfloop> <!--- use a simple database query to check the results of the import - dumping query to screen ---> <cfquery name="rscsvdemo" datasource="#REQUEST.dataSource#"> SELECT * FROM datefield2 </cfquery> <cfdump var="#rscsvdemo#"> |
Mailing Lists
|
Latest Fusion Authority Articles
|