Saturday, November 23, 2002, 5:37:57 AM, you wrote:
SC> I'm reading a txt file which has 3 fields to a line
SC> eg

SC> 14||'Maggin, Elliot S.'
SC> 15||'Maine, Charles Eric'
SC> 16|1|'McCaffrey, Anne'

SC> but often the second field is empty

SC> Lists don't believe an empty field exists so I keep getting errors when I 
SC> try to loop over the list to import to a database

SC> How can I make the list a true believer? (in accepting empty fields?)

listToArray(list, "|") might do the trick. Then each of your fields
would be an element in the array, even the null ones.

SC> Or is there an alternative way to import the data?  (access database and 
SC> ColdFusion 5)

Set up an ODBC Text Datasource for the file if you have a text driver
on the machine. It requires less code, and is magnitudes faster than
converting a csv to a query with CF logic. Once the datasource is set
up, it's one cfquery to convert the entire csv to a query.

<cfquery datasource="textDSN" name="qry">
SELECT *
FROM [foo.csv]
</cfquery>

I know CF5 Enterprise comes with the Merant text drivers, and the
Microsoft text drivers work very nice as well. I'm just not sure if they
get installed with Access or just with SQL Server.

You could also try bypassing all the insanity directly and using
the Link Table function to link the text file directly to the
database. No need to do anything then...the text file is already part
of the database.

-- 
jon
mailto:[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to