Copy link to clipboard
Copied
Hi i tried to upload the csv file to database and i am getting error as
<cffile action="read" file="#data_dir_upload#/di_audit_corp_upc_ldr_tbl.csv" variable="di_audit_corp_upc_ldr_tbl">
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#di_audit_corp_upc_ldr_tbl#" delimiters="#chr(10)##chr(13)#">
<cfquery datasource="#request.dsnCAO#">
<!--- SET ANSI_WARNINGS OFF --->
INSERT INTO [dbo].[di_audit_corp_upc_ldr_tbl]
( cpt_dpt_cd,cpt_com_cd,sub_com_cd,con_upc_no,pid_lng_dsc_tx,pid_sht_dsc_tx)
VALUES
(<cfqueryparam value='#left(trim(listgetAt('#index#',2,',')),2)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',3,',')),3)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',4,',')),5)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',1,',')),13)#' cfsqltype="cf_sql_varchar">,
<cfqueryparam value='#left(trim(listgetAt('#index#',5,',')),25)#' cfsqltype="cf_sql_varchar">,
<cfqueryparam value='#left(trim(listgetAt('#index#',6,',')),12)#' cfsqltype="cf_sql_varchar">)
</cfquery>
</cfloop>
Error:
An error occurred while executing DTS package to import data.
Invalid list index 6.
In function ListGetAt(list, index [, delimiters]), the value of index, 6, is not a valid as the first argument (this list has 5 elements). Valid indexes are in the range 1 through the number of elements in the list.
i am unable to solve this issue can any one will help me to solve this issue
Thanks,
Kiran
Copy link to clipboard
Copied
Have another look at the text di_audit_corp_upc_ldr_tbl. Coldfusion is convinced it has just 5 lines.
Copy link to clipboard
Copied
Hi,
Verify Your CSV file is well formatted or not
Copy link to clipboard
Copied
There are two common issues when importing csv files. One is empty elements. The other is commas as part of the data. You need a strategy to deal with each.
Copy link to clipboard
Copied
Hi,
According to my current requirement I want to know is there simple Flex compatible parser for use in parsing CSV (comma separated value) format files. This may already be available in Flex Builder. If not what is the best way to parse these files.
Regards
Kalavati Singh
kalavati_singh@yahoo.co.in
Copy link to clipboard
Copied
I take it your are trying to use a csv file to insert new data into a database, using flex and coldfusion?
if so, then I would load the file in flex using cffile in ColdFusion and then use Load Data if you are using MySQL
This can show you more about it.
We get very large csv files ftp'd to us every week, and we have to load them in to the db. this works for us.
Copy link to clipboard
Copied
KalavatiSingh,
I have not used it, but there is a CSV library for Actionscript at code.google.com.
http://code.google.com/p/csvlib/
You might also post this question in a Flex/Actionscript specific forum.
http://forums.adobe.com/community/flex