Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile

Status
Not open for further replies.

cfhelp

Programmer
Jan 11, 2006
11
US
How do you read a file into a table?

Thanks in advance.
 
I'm assuming your file is in a particular format.

Using sql server you can use dts to import the data i think you can also do this in coldfusion.

TO so it using cffile you would need to loop over the contents of the file line ny line (check for the newline operator) and then save each row into the database. Your row will need to have the fields seperated and you will have to be able to determine when fields are blank.

Finally i think there are tags to do this on the developer exchange at macromedia.com

HTH

 
Thanks pigsie,

My file contains:

SSN, Name, Address, Title, StartDate, EndDate

Here is what I have:

<cffile action = &quot;read&quot; File = &quot;#outfile#&quot; variable = &quot;txtinput&quot;>

<cfset myarray = ListToArray(txtinput)>

<cfloop from = &quot;1&quot; to= &quot;#arraylen(myarray)#&quot; index = &quot;this&quot;>
<cfoutput>#myarray[this]#</cfoutput>
</cfloop>

Now that the file is in an array, how would I loop through it and insert into the database?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top