I am importing a tab delimited text file, and have a few problems.The software I'm writing in is VB6. The text file being imported, has text on the first 50 lines. The rest of the text file, has numeric values in a tab delimited format. The text on the first 50 lines, needs to be deleted, and the rest of the numeric values, needs to be written to a temporary file named "temp.dat". A sample of the first 50 lines of text data on the imported file is as follows: ~VERSION INFORMATION VERS . 2 : CWLS Log ASCII Standard Version WRAP . NO : One Line per Depth Step
The numeric values in the same file, starting at line 51, is as follows: 9010 4.083 34.38 6876 0 0 0 0 0 34.38 0.00 6.4 0.0 0 0.0000 0.00 0.00 0.0 0.00 04:27:55 2009/12/22 If I manually delete the first 50 lines of data, this code works. I would like to programmatically delete the first 50 lines, and then copy the rest of the values into the "temp.dat" file. The code I have follows: [CODE] Private Sub Command1_Click() Dim FileNum As Long Dim TotalFile As String Dim Records() As String Dim X As Long Dim Columns() As String 'delete header-first 50 lines 'this is where I am stuck ' Let VB generate the file channel number FileNum = FreeFile ' Reads the whole file into memory all at once Open "C:\DB_CUE\iball las.las" For Binary As #FileNum 'edited file TotalFile = Space(LOF(FileNum)) Get #FileNum, , TotalFile Close #FileNum
Next X Close #2 END SUB [/CODE] Do you have any professional advice on how to approach this? Much help is greatly appreciated. I have researched the net and forums, and have come up with the code provided. Now I am stuck. All help is much appreciated. Thanks Answer from Richard Rost:
Why not just open the file for reading, open a temp file for writing, loop from 1 to 50, read in a line and do nothing, then at line 51 start writing the data out to your temp file line by line. Now, once you've got this temp file made, analyze THAT file for your data. Would this work for you? If it's always 50 lines of junk, I don't see why not.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Visual Basic Forum.