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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing text file in sequencial order 1

Status
Not open for further replies.

vzjfgm

Programmer
Jul 24, 2003
34
US
I am having a problem importing a text report file. I need to import it in the exact record order as the original report file. When I import it via import specification file the order changes. The report in chopped up in pieces.
I do not have any indexes on the file. Any suggestion?
 
The only way I have been enable to ENFORCE file line order is to create my import routine using the File In/Out functions.

I can OPEN a file, read the first line, do whatever, read the next line, do whatever, etc to the end of the file, CLOSE the file...

Not as graceful, much more work, but it has always worked for me....

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
mstrmage1768,

You can improve the 'grace' of your approach a bit (and speed up the operation on larger files). Search these fora for 'basGrabFile'. It has been posted several times, and at least one of the posts has a brief example of how to use it, although with all of the alphabet soup you have earned you should not actually need any help understanding the procedure or its advantages.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
MichaelRed,

Thanks....that is nice....

Fortunately for me, most of this time the files I work with are only a couple of megs...so I am not seeing a DRAMATIC improvement.....but I created a short (35M) sample file, and compared the two processes.....as you idndicated...a good 50-75% increase.

Well Done. Have a star on me.

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Gentlemen,

May I offer another solution?

Create a table called tmpImport, the structure of which matches roughly that of the intended importee; for example

field1 Text Size=255
field2 Text Size=255
field3 Text Size=255
field4 Text Size=255
field5 Numb Size=Autonumber (Indexed, Sequential, Unique, Asc Order)

The last field in the table should be the AutoNumber type (a gastly "feature" but has its uses).

Use the DoCmd.TransferText routine to import the importees records into tmpImport. Each record will be allocated a number during its import thereby self-sorting the records.

One can transfer the data from this table to the Master and Child tables using queries. Or the data can be examined for inconsistencies.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top