As far as I can see there's really no middle-ground between reading the entire file into memory, or scanning the file every time a new row is requested.
If you read the file into memory you could destroy your data structure as rows are fetched. You'll slowly recover your memory.
If you're scanning down the file you could remember the seek positions of the end of each column for each line in the file. Seeking instead of reading and discarding lines may be a bit faster, but then, the extra complexity may simply not be worth it.
I think your best bet is a heuristic; if the file is larger than some threshold, use the slow scan; if it's smaller, read it into memory.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.