On Jan 29, 2008 1:35 PM, Hannah Drayson <[EMAIL PROTECTED]> wrote:
> It imports as a string of rubbish...
> i.e.
>
> <open file 'data.bin', mode 'rb' at 0x5a2a8>
> >>> text = f.read()
> >>> print text
> ?F?C??y??>?
> @[EMAIL PROTECTED]@???????????????????/???8@@@@[EMAIL PROTECTED]/[EMAIL 
> PROTECTED]@?????Q???Q???Q???Q???Q??Ǒ????????R[???Q???????
> >>> unpack('d', text)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/struct.py",
>  line 87, in unpack
>     return o.unpack(s)
> struct.error: unpack requires a string argument of length 8

When reading the file, try using
file = open('data.bin', 'rb')
file.seek(0)
raw = file.read()

Do the unpack on "raw".
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to