start the reading file from...
I use the tipical function:
....
Open file For Input As #1
...
ecc...
to reading txt file line by line.
But instead to init the redaing line by line...
1) I need to find, in position mid(line, 1,8), the string INIT0000 and strat the reading of lines from here
2) stop the reading of line from file wehen the code found in mid(line, 1,8), the string INIT0001
please a fast method to find the first line because have perphs 2.300.000 of lines in original txt file:eek::bigyello:
note:
no possible duplicate string in position mid(line, 1,8)
Re: start the reading file from...
Re: start the reading file from...
Quote:
Originally Posted by
seenu_1st
test exampe in link...
But each code give error about memory...
Remember i have aprrox 2.300.000 lines in txt file:sick::eek::confused:
Re: start the reading file from...
Unless every line is exactly the same length, you have no way of being able to jump to a specific line in the file.
Reading the entire file into memory works well for small files, not large files (depends on system resources)
1. Either loop line by line until you get to the line you are looking for, or
2. Open the file for BINARY and read a chunk of the file at once. You can play with the chunk size to optimize performance. Maybe start out at like 32kb at a time and go all the way to 500kb at a time
- There are projects in the CodeBank section for searching a file quickly. Think those might help
- The problem with searching chunks is that if the criteria you are searching for happens to be split between chunks. Solving this problem is easy enough, when criteria not found in current chunk, start reading the next chunk a few bytes (length of your criteria) before where the current chunk ended. By opening file as Binary, you can tell it where to start reading each time you attempt a read
Re: start the reading file from...
Quote:
Originally Posted by
LaVolpe
Unless every line is exactly the same length, you have no way of being able to jump to a specific line in the file.
Reading the entire file into memory works well for small files, not large files (depends on system resources)
1. Either loop line by line until you get to the line you are looking for, or
2. Open the file for BINARY and read a chunk of the file at once. You can play with the chunk size to optimize performance. Maybe start out at like 32kb at a time and go all the way to 500kb at a time
- There are projects in the CodeBank section for searching a file quickly. Think those might help
- The problem with searching chunks is that if the criteria you are searching for happens to be split between chunks. Solving this problem is easy enough, when criteria not found in current chunk, start reading the next chunk a few bytes (length of your criteria) before where the current chunk ended. By opening file as Binary, you can tell it where to start reading each time you attempt a read
not for me tks friend:blush::confused:
can i send my txt file and chat in msger or skipe or fb?
Re: start the reading file from...
Quote:
Originally Posted by
LaVolpe
Unless every line is exactly the same length, you have no way of being able to jump to a specific line in the file.
Reading the entire file into memory works well for small files, not large files (depends on system resources)
1. Either loop line by line until you get to the line you are looking for, or
2. Open the file for BINARY and read a chunk of the file at once. You can play with the chunk size to optimize performance. Maybe start out at like 32kb at a time and go all the way to 500kb at a time
- There are projects in the CodeBank section for searching a file quickly. Think those might help
- The problem with searching chunks is that if the criteria you are searching for happens to be split between chunks. Solving this problem is easy enough, when criteria not found in current chunk, start reading the next chunk a few bytes (length of your criteria) before where the current chunk ended. By opening file as Binary, you can tell it where to start reading each time you attempt a read
Friend have you see my last reply on this question...?
Re: start the reading file from...
You can start reading any specific line or byte location of a file, provided that you have a unique identifier that isolates the location for the initial read. Sometimes I first index huge files and establish the byte positions in a separate indexing file that I use to store those positions. Then I use either the Seek or Get statement to jump immediately to the location.
Ending the read can then be accomplished by using a delimiter character that stops the reading by looking ahead using Instr(). In between is the string information that you need for your application.