If it's a clean table your best bet is probably to import it as a csv using
what ever DB you have.  I have found that importing CSV files into access
and SQL Server is nice and easy.

If you are appending this data to an existing table, then you will need to
change this up some.  I have commented it to show what it's doing.  Should
work for you, may be some minor mistakes since I haven't tested it.  This
should work:

<!--- READ FILE FROM FILE SYSTEM --->
<CFFILE ACTION="Read" FILE="C:\email_lista2.csv" VARIABLE="emailtext">

<!-- loop the file based off of the line delimiter, you may need to check
and see if there are two line delimiters --->
<CFLOOP INDEX="csvRow" LIST="#emailtext#" delimiters="#chr(13)">

<!--- now that you have one row, break out each part --->
<CFSET emailName = listGetAt(csvRow, 1)>

<!--- get the second element of the list which is both the email address and
the company name --->
<CFSET emailPart = listGetAt(csvRow, 2)>

<!--- get the email address --->
<CFSET emailAddress = listGetAt(emailPart, 1, " ")>

<!--- now since the company name may have spaces it's a bit more difficult.
First get the index of the first space --->
<CFSET start = find(emailPart, " ")>

<!--- now grab everything from the first space to the end of the row --->
<CFSET emailCompany = right(emailPart, len(emailPart) - start)>

<!--- INSERT INTO TABLE --->
<CFQUERY NAME="insrt" datasource="#datasource#">
        insert into Email
        (
        email_address,
        email_name,
        email_company,
        )
        values
        (
        '#emailAddress#',
        '#emailName#',
        '#emailCompany#'
</cfquery>

</CFLOOP>

Tim Heald
ACP/CCFD :)
Application Development
www.schoollink.net

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 24, 2002 12:03 PM
> To: CF-Talk
> Subject: <CF_Array_help>
>
>
> Hey,
>
> I'm not good at arrays and could use some help.  I'm
> trying to import a *.csv file with three columns into
> a table.  The csv file look like ...
>
> Donna Jackson,[EMAIL PROTECTED] Drew Corporation,
> Douglas Car,[EMAIL PROTECTED] Drew Corporation,
>
> Here's what I have for code so far ...
>
> 1) Should I be adding to an 3 dimensional array as I
> loop through the list?
> 2) How do I reference each element in the array for the
> insert?
>
> <CFSET emailtext=ArrayNew(1)>
>
> <!--- READ FILE FROM FILE SYSTEM --->
> <CFFILE ACTION="Read"
>           FILE="C:\email_lista2.csv"
>         VARIABLE="emailtext">
>
> <!--- REPLACE THE COMMA WITH A BLANK --->
> <CFLOOP INDEX="fred" LIST="#ReplaceList
> (emailtext, ",", "")#" delimiters="">
>
> <!--- INSERT INTO TABLE --->
> <CFQUERY NAME="insrt" datasource="#datasource#">
>       insert into Email
>          (
>               email_address,
>               email_name,
>               email_company,
>               )
>               values
>               (
>                 '#VALUE_COLUMN1#',
>                 '#VALUE_COLUMN2#',
>                 '#VALUE_COLUMN3#'
> </cfquery>
>
> </CFLOOP>
>
>
> Thank you in advance.
>
> D-
> 
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to