|
-
Sep 2nd, 2011, 01:26 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|