Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

reading a text file and inserting into database

What is the best possible way to read the text file which has around 10000 records and each column is separated by tab or comma and has 10 columns for every single row

what is the best possible way to do it in coldfusion
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Coast Line

ASKER

but what if i needs through a way in coldfusion, i know that will far less slower but right now that may serve the purpose
Both can be used from ColdFusion.  It's no different than any sql command.

If you must parse it manually, there's plenty of examples on parsing CSV files.  The logic is exactly the same for tab delimited files.

* Treat it as a list delimited by new chr(10) chr(13)
* As you loop, split each line into columns using list functions, delimiter "," or chr(9)
* Insert the values into the db

https://www.experts-exchange.com/searchResults.jsp?searchTerms=ColdFusion+loop+CSV&searchType=10
Thanks Guys, I know parsing of text files but i was acquiring info as to how we can do better in coldfusion like fast processing rather than depending upon list
Well like I said above, the fastest method is let the db do the importing.  Both commands can be used in a cfquery.  I do it all the time.