Extract double in binary file

Gandalf gandalf at geochemsource.com
Wed Nov 26 10:19:29 EST 2003


>
>
>I've a binary file with data in it.
>This file come from an old ms dos application (multilog ~ 1980).
>In this application, a field is declared as a 'decimal' (999 999
>999.99).
>I put 0.00 in the field and save the record to the file.
>When I look in the binary file (with python or an hex editor), the
>field is stored on 8 bytes: 00-00-00-00-00-00-7F-00.
>I try unpack from struct module but the result isn't good.
>
>Can someone help me?
>  
>
Most likely it is a BCD field. Please watch for number in the file with 
a simple text
viewer. In that case, you can read the number as a string (length is 
len('999999999.99')
or similar) and convert it with int() or long().

Cheers,

   L







More information about the Python-list mailing list