Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

error for the uploading csv file to database

New Here ,
May 06, 2009 May 06, 2009

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

TOPICS
Advanced techniques
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2009 May 08, 2009

Have another look at the text di_audit_corp_upc_ldr_tbl. Coldfusion is convinced it has just 5 lines.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 14, 2009 May 14, 2009

Hi,

Verify Your CSV file is well formatted or not

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2009 May 14, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 25, 2009 May 25, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 29, 2009 Jun 29, 2009

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.

http://blog.tygate.com/?p=75

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 30, 2009 Jun 30, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources