[FRPythoneers] Random File Access

J. Wayde Allen wallen at its.bldrdoc.gov
Tue Dec 23 20:46:54 MST 2003


I have a number of large (gigabyte) binary files from which I need to
extract blocks of data.  I'm thinking I could write something like:

   for i in range(x):
      chunk = file.read(4)

that would step through in multiples of four byte chunks extracting what
I need as it goes by.  I could maybe even simplify this and eliminate the
'for' loop making this:

   chunk = file.read(x)

so that I'd read x bytes at a time.  However, I'm wondering if there is a
more efficient mechanism or a way to perform a random access to the file
data?  I do have information in the file that gives byte offsets to where
these data I need are located.

- Wayde
  (wallen at its.bldrdoc.gov)

      --------------------------------------------------------
                            ISART 2004
       International Symposium on Advanced Radio Technologies
         http://www.its.bldrdoc.gov/meetings/art/index.php
      --------------------------------------------------------






More information about the FRPythoneers mailing list