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 <v...@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
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to