Re: Read header and data from a binary file [LONG]

2009-09-25 Thread Gabriel Genellina
En Tue, 22 Sep 2009 18:18:16 -0300, Jose Rafael Pacheco jose_rafael_pach...@yahoo.es escribió: Hello, I want to read from a binary file called myaudio.dat Then I've tried the next code: import struct name = myaudio.dat f = open(name,'rb') f.seek(0) chain = 4s 4s I 4s I 20s I I i 4s I 67s s

Read header and data from a binary file [LONG]

2009-09-23 Thread Jose Rafael Pacheco
Hello, I want to read from a binary file called myaudio.dat Then I've tried the next code: import struct name = myaudio.dat f = open(name,'rb') f.seek(0) chain = 4s 4s I 4s I 20s I I i 4s I 67s s 4s I s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1) a =

Re: Read header and data from a binary file [LONG]

2009-09-23 Thread Ishwor
Jose, Hi Note: I've worked with struct but a while ago so might be rusty a bit. Also, this sounds a bit like a homework. If it is a homework please do it yourself(or at least try) as you'd otherwise never know the knowledge behind it on real-world scenario :-) Having said that I am giving you

Re: Read header and data from a binary file [LONG]

2009-09-23 Thread Ishwor
char is 1 bytes long on Python (as per struct modules' definition) Also, this is also another option for you to use instead of built-in struct. http://www.sis.nl/python/xstruct/xstruct.shtml -- Regards, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-list

Read header and data from a binary file

2009-09-22 Thread Jose Rafael Pacheco
Hello, I want to read from a binary file called myaudio.dat Then I've tried the next code: import struct name = myaudio.dat f = open(name,'rb') f.seek(0) chain = 4s 4s I 4s I 20s I I i 4s I 67s s 4s I s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1) a =

Re: Read header and data from a binary file

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 4:30 PM, Jose Rafael Pacheco jose_rafael_pach...@yahoo.es wrote: Hello, I want to read from a binary file called myaudio.dat Then I've tried the next code: import struct name = myaudio.dat f = open(name,'rb') f.seek(0) Don't bother to seek(0) on a file you just

Re: Read header and data from a binary file

2009-09-22 Thread MRAB
Jose Rafael Pacheco wrote: Hello, I want to read from a binary file called myaudio.dat Then I've tried the next code: import struct name = myaudio.dat f = open(name,'rb') f.seek(0) chain = 4s 4s I 4s I 20s I I i 4s I 67s s 4s I s =