Fast file data retrieval?

Dan Stromberg drsalists at gmail.com
Mon Mar 12 21:33:26 CET 2012


If the ID's are sorted, you could probably rig a binary search using seek.
This'll be easier if the records have a constant length, but it's still
possible for variable-length, just messier.

Otherwise you could stash them all in a dictionary (in memory) or anydbm
(on disk) to get indexed access.

On Mon, Mar 12, 2012 at 12:39 PM, Virgil Stokes <vs at it.uu.se> wrote:

>  I have a rather large ASCII file that is structured as follows
>
> header line
> 9 nonblank lines with alphanumeric data
> header line
> 9 nonblank lines with alphanumeric data
> ...
> ...
> ...
> header line
> 9 nonblank lines with alphanumeric data
> EOF
>
> where, a data set contains 10 lines (header + 9 nonblank) and there can be
> several thousand
> data sets in a single file. In addition,* each header has a* *unique ID
> code*.
>
> Is there a fast method for the retrieval of a data set from this large
> file given its ID code?
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120312/cac6e38c/attachment.html>


More information about the Python-list mailing list