Noobie: Open file -> read characters & multiply

gonzlobo gonzlobo at gmail.com
Wed Dec 27 13:01:20 EST 2006


Thanks to all that responded. I chose a modified version of Scott's
second recommendation:

time = line[:8]
decoded_File.write( '%00.4f' % (int(time, 16) * .0001) + ', ')

'print >>' added a CRLF that I didn't need, so I went with '.print' (I
need to process about 20 values from the remaining bytes).

Thank you.

On 12/26/06, Scott David Daniels <scott.daniels at acm.org> wrote:
...
> > Any help is really appreciated.
> for line in AP_file:
>      print >>decoded_File, '%s.%04d' % divmod(int(line[:8], 16), 10000
>                                               ), line[9:].rstrip()
>
> or:
>
> for line in AP_file:
>      print >>decoded_File, '%.4f' % (int(line[:8], 16) * .0001
>                                               ), line[9:].rstrip()
...



More information about the Python-list mailing list