Reading binary from a file...
Steve Holden
steve at holdenweb.com
Wed Mar 8 01:57:54 EST 2006
KraftDiner wrote:
> Hi!
> In python I'm able to read in binary data from a file.
> data = file.read() # Reads in an entire file.
>
Note that you should open the file in binary mode to be
platform-agnostic and as portable as possible. (Just in case you aren't).
> However the data is 16bits per sample and python is storing the
> data in a string. How do I convert that 8bit data into a list of 16
> bit integers?
>
> Note: I want generic python lists or tupels not numpy or numeric etc
> etc...
>
You really want the struct module here.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com
More information about the Python-list
mailing list