Jump to a Line Number in a very Large Text File Tool

ions

Access User
Local time
Today, 13:08
Joined
May 23, 2004
Messages
823
Dear MS Access Expert.

I have a large txt file with around 500,000 lines. There is an error on line 330656.

I want to be able to jump to this line within the text file and see what the error is.

What tool would you use to do what I want? Is there a free download?

Thank you very much.
 
Dear MS Access Expert.

I have a large txt file with around 500,000 lines. There is an error on line 330656.

I want to be able to jump to this line within the text file and see what the error is.

What tool would you use to do what I want? Is there a free download?

Thank you very much.

If it were me, I would just use your VBA code.

Add a line counter variable and a simple loop. Put a break point to stop when it gets to the line with an error.

Also have you tried WordPad?
 
Hi HiTechCoach.

WordPad opens the file quickly and works great but I couldn't find an option to display Line Number.

I checked the Web and it appears it doesn't have that option.

Thanks
 
What HTC was implying is that you use the following logic


Code:
Dim sText as String
Dim rIndex As Long

Open TextFile for Input As#1

Do Until EOF(1)
   rIndex = rIndex + 1
   If rIndex = 330656 Then
      Line Input #1, sText
      Debug.Print sText
      Exit Do
   End If
Loop

Close #1
 
David-

Close, but no cigar:

Code:
Dim sText as String
Dim rIndex As Long
 
Open TextFile for Input As#1
 
Do Until EOF(1)
   Line Input #1, sText
   rIndex = rIndex + 1
   If rIndex = 330656 Then
      Debug.Print sText
      Exit Do
   End If
Loop
 
Close #1


John Viescas, author
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
 
give us a clue!!!

i've not tested this, but it cant be far off.

other than textfile not being a literal, and rindex not being preset to 0, what exactly is the problem?
 
The Line Input should be before the If otherwise it doesn't advance the line just the counter.

Code:
Do Until EOF(1)
   rIndex = rIndex + 1
   Line Input #1, sText
   If rIndex = 330656 Then
      Debug.Print sText
      Exit Do
   End If
Loop
 
Galaxium is exactly correct.

John Viescas, author
Microsoft Office Access 2007 Inside Out

Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
 
i must be going blind - i really thought the code in DC's block and the code in JV's block were exactly the same
 
As I always tend to mention as a caveat code is untested and air code and any table/fieldnames are for brevity only. However the concept is correct.
 
The reason I recommend using modifying the VBA Code to stop at the line with an issue is so that you can use all the power of the debugging tools to modify the code "live" (executing) and still processing the actual data.

while that's true (and I've used that method many times), sometimes eyeballing the data gives you a clue to what's wrong, or that the data is not what you think it is (different layout... could spot that in seconds). YMMV
 
You could also arrange the code to display any number of lines before and after the target line.
 

Users who are viewing this thread

Back
Top Bottom