Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Winston2 #1
Re: How do I parse a txt File and write data into aDatabase
I'm trying to do an insert off of your example. It keeps throwing an error that
it doesn't understand "fields1."
Can you tell me where I might be going wrong? Thank you.
<!--- Example of looping through a tab delimited text file ---->
<cffile action="read" file="C:\web\LD\LTReview2005\admin\upload\inputDat a.txt"
variable="FileData">
<!--- use the appropriate row/field delimiters for your file --->
<cfset rowDelim = chr(13)&chr(10)>
<cfset fieldDelim = chr(9)>
<cfloop list="#FileData#" delimiters="#rowDelim#" index="currLine">
<!--- determine the number of fields in this record --->
<!--- using field delimiter tab character char(9) --->
<cfset fields = ListToArray(currLine, chr(9))>
<cfif ArrayLen(fields) eq 9>
<cfloop from="1" to="9" index="i">
<!--- output fields --->
<cfoutput>
<b>f#i#:</b> #fields#
</cfoutput>
<!--- Returns max_ID --->
<cfmodule template="../../CustomTags/Max_ID.cfm"
datasource="#application.DSN#" tablename="LTREmp" PrimaryKey="LTREmpID">
<!--- Insert to add a person to be reviewed. --->
<cfquery name="addEmployee" datasource="#application.DSN#" dbtype="ODBC">
INSERT INTO LTREmp
(LTREmpID, emplNo, empName, mgrEmplNo, HireDate, JobTitle, managerName,
orgCode, dept)
VALUES
(#Max_id#, '#fields1#', '#fields2#', '#fields3#',
<cfif #fields4# eq "">
null,
<cfelse>
#CreateODBCDate(fields4)#,
</cfif>
'#fields5#',
'#fields6#',
'#fields7#',
'#fields8#'
)
</cfquery>
</cfloop>
<br>
</cfif>
</cfloop>
Winston2 Guest
-
BUG: An 8144 error occurs when you try to attach adatabase to an instance of SQL Server by using SQL ServerEnterprise
Hi guys... just wondering if any of you have come up with a 8144 database error... I'm getting this through calling cfstoredproc with more than... -
advice needed... cf write data to xml file for use in flash app thatuses xml file
I'm wondering if it is possible to use CF to: 1) connect to existing db; 2) get specific data from table; 3) write it to an xml file that would... -
Need to Parse one value from two lines of data
Hi, I'm doing a cfhttp request to a shipping rate provider and the response I get back looks like this: GND, NAS, SDS, EXP $6.50, $12.25,... -
Can you parse data by an undefined pattern ?
Hi JS if there is consistency within the inconsistency then; I usually attack this kind of situation on a progressive yield hope and write a... -
Parse Text File and Output to File
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines...



Reply With Quote

