Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get text at line-nr from large texfile using "File f.open"
#1
Sorry this should be very simple but somehow I am overlooking something.

I have a textfile containing 40.000 lines.
I want to get the text on linenumber 1100.

Is it possible to do it without the .getfile function or without putting the whole textfile into an array or Icsv object?

I have this code:

Macro Macro18
Code:
Copy      Help
str s="D:\_TMP\test.txt"
File f.Open(s)
f.SetPos(1100)
f.ReadLine(s)
out s

The problem is, that the SetPos function puts the position at character at character-number, but I want to put the position at line-number 1100 and then extract the line at that position.
Is it possible?

I am assuming that the code beneath accesses the text file 1100 times (line by line).
I want to avoid unnecessary reads.

Macro Macro18
Code:
Copy      Help
int i
for i 0 1100    
,if(!f.ReadLine(s))
,,break
,if(i=1100)
,,out s ;; I want this line (1100)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)