Help please with binary file read

Discussion in 'Python' started by Stewart Arnold, Jan 1, 2006.

  1. I'm trying to convert a Real Basic routine into Python and I can't read the
    long integer data from a file.

    Here is the Real Basic code:

    b=f.OpenAsBinaryFile
    b.LittleEndian=True
    i=b.ReadByte
    titles=b.ReadLong
    shows=b.ReadLong
    i=b.ReadLong

    And here is my code:

    db = open('otter.db', 'rb')
    null = db.read(1) # read empty byte
    titles = db.read(4)
    shows = db.read(4)
    null = db.read(1) # read empty byte

    print titles

    When I print titles I get ascii pictures. How do I convert 'titles' to an
    integer I can loop through?
    Is db.read(4) correct for ReadLong?

    Thanks!

    PS. here's the file I'm working with http://otterprojectonline.info/otter.db
     
    Stewart Arnold, Jan 1, 2006
    #1
    1. Advertising

  2. On 2006-01-01, Stewart Arnold <> wrote:

    > I'm trying to convert a Real Basic routine into Python and I
    > can't read the long integer data from a file.


    http://docs.python.org/lib/module-struct.html

    --
    Grant Edwards grante Yow! Here I am in 53
    at B.C. and all I want is a
    visi.com dill pickle!!
     
    Grant Edwards, Jan 1, 2006
    #2
    1. Advertising

  3. Grant

    Perfect!

    Thanks :)
    Stewart

    "Grant Edwards" <> wrote in message
    news:...
    > On 2006-01-01, Stewart Arnold <> wrote:
    >
    >> I'm trying to convert a Real Basic routine into Python and I
    >> can't read the long integer data from a file.

    >
    > http://docs.python.org/lib/module-struct.html
     
    Stewart Arnold, Jan 1, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug
    Replies:
    3
    Views:
    4,417
    Bruce Barker
    Nov 4, 2005
  2. Replies:
    4
    Views:
    570
    Chris Uppal
    May 5, 2005
  3. KK
    Replies:
    2
    Views:
    728
    Big Brian
    Oct 14, 2003
  4. Sniper Abandon
    Replies:
    3
    Views:
    256
    Robert Klemme
    Nov 19, 2009
  5. Alex Dowad
    Replies:
    4
    Views:
    323
    Michel Demazure
    May 1, 2010
Loading...

Share This Page