For a value/pair list you can loop over the file contents using 
delimiters="#chr(13)##chr(10)#" and then use ListGetAt() with "=" as delimiter.

Here's some similar code that drops the info into a DB:

<!--- clear the old stuff --->
<cfquery datasource="#application.Datasource#">
  DELETE FROM tablename
</cfquery>
<!--- read the file --->
<cffile action="read" file="#filepath#" variable="l_CsvList">
<cfset l_LineDelim = chr(13) & chr(10)>
<cfset l_ColDelim = ",">
<!--- Get rid of the quotes --->
<cfset l_Replace='"'>
<cfset l_CsvList = Replace(l_CsvList,l_Replace,"","ALL")>
<cfset l_CsvList = Replace(l_CsvList,"#l_ColDelim##l_ColDelim#","#l_ColDelim# 
#l_ColDelim#","ALL")>
<!--- loop throug and insert each --->
<cfloop list="#l_CsvList#" index="l_ThisRow" delimiters="#l_LineDelim#">
  <cfscript>
    l_LastName=Trim(ListGetAt(l_ThisRow,1,l_ColDelim));
    l_FirstName=Trim(ListGetAt(l_ThisRow,2,l_ColDelim));
    l_District=Trim(ListGetAt(l_ThisRow,3,l_ColDelim));
    l_Club=Trim(ListGetAt(l_ThisRow,4,l_ColDelim));
    if (NOT IsNumeric(l_District)) { l_District = "NULL"; }
  </cfscript>
  <cfquery datasource="#application.Datasource#">
    INSERT INTO tablename (District,LastName,FirstName,Club)
    VALUES (#l_District#, '#l_LastName#', '#l_FirstName#', '#l_Club#')
  </cfquery>
</cfloop>

>>> [EMAIL PROTECTED] 08/21/02 04:06PM >>>
Anybody have a snippet of code that will read and parse the contents of a
text file? An .ini file, perhaps, with key=value pairs on each line.

Thanks.


-- 
Al Everett
Allied Office Supplies
www.askallied.com 
mailto:[EMAIL PROTECTED] 
v: 973-594-3209
f: 973-594-3626

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
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