Combine # text files but remove first line from all but 1

chris-uk-lad

Registered User.
Local time
Today, 02:37
Joined
Jul 8, 2008
Messages
271
Hi,

Each month i get several text files which i want to load into a table in access via VB. Atm this is a slow process so would like to automate this with VB, by combining the text files together then exporting into the database. I know the DOS command to combine the files

copy filename1.txt +filename2.txt +filename3.txt file.txt

but this includes all the headers and i only wish to keep the headers of the first text document. Anyone know a method of deleting the first line from all but the first text file?

Many Thanks
 
Use open file for output as #1 to create the masterfile

then use open file for input as #2 for each incoming file

use a Do Until EOF with a row counter ( iRow = iRow +1)
Then use an If statement

If iRow > 1 then
Read the row from #2
write to #1 (master)
End If

Close the #2 (input file)

put all this in a loop that get the files from the known folder

When finished close #1 (master)

Tip! Add the name of the input file to end of the incoming line and append it the master text file. That way you can see which files have been merged.

David
 

Users who are viewing this thread

Back
Top Bottom