reading binary data written in C

Discussion in 'Python' started by Sheldon, Mar 22, 2006.

  1. Sheldon

    Sheldon Guest

    Hi,

    I have a script that I want to use to read some binary lon and lat data
    that was written with a C program. My script looks like this:
    
    lat = open(lat_file,'rb').read()
    lat = Numeric.fromstring(lat)
    print len(lat)
    print lat[0]

    Results:
    1476225
    -995001790

    Or using the Float typecode:
    Results:
    1476225
    -1419.82055664
    **************************

    Now the length of the string is good, a 1215*1215 array in vector form.
    But the lat data is wrong.
    I have tried different type codes but nothing gives me a lat that is
    within [+90,-90] degrees.
    Does anyone know what is going on here?

    Thanks,
    Sheldon
    Sheldon, Mar 22, 2006
    #1
    1. Advertising

  2. On 2006-03-22, Sheldon <> wrote:

    > I have a script that I want to use to read some binary lon and lat data
    > that was written with a C program.


    http://www.python.org/doc/current/lib/module-struct.html

    --
    Grant Edwards grante Yow! UH-OH!! We're out
    at of AUTOMOBILE PARTS and
    visi.com RUBBER GOODS!
    Grant Edwards, Mar 22, 2006
    #2
    1. Advertising

  3. Sheldon

    Sheldon Guest

    Thanks,

    I later discovered that it was a big edian binary as well.

    Sheldon
    Sheldon, Mar 22, 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. Steve C. Orr, MCSD
    Replies:
    1
    Views:
    547
    reaway lee
    Aug 24, 2003
  2. cobol and binary data written by C

    , May 9, 2004, in forum: C Programming
    Replies:
    5
    Views:
    503
    Lew Pitcher
    May 10, 2004
  3. Sandeep
    Replies:
    3
    Views:
    286
  4. roughtrader
    Replies:
    3
    Views:
    433
    James Kanze
    Feb 17, 2009
  5. KaiWen
    Replies:
    102
    Views:
    2,640
    Jorgen Grahn
    Sep 15, 2011
Loading...

Share This Page