Re: parse binary file

2012-01-29 Thread Steven D'Aprano
On Sun, 29 Jan 2012 15:50:49 +0100, Aaron wrote: > On 01/29/2012 03:04 PM, Andrea Crotti wrote: >> On 01/29/2012 07:51 AM, contro opinion wrote: >>> please download the attachment ,and put in c:\test.data >>> >>> >> Your program should never use hard-coded path, and actually I think the >> majori

Re: parse binary file

2012-01-29 Thread Aaron
On 01/29/2012 03:04 PM, Andrea Crotti wrote: On 01/29/2012 07:51 AM, contro opinion wrote: please download the attachment ,and put in c:\test.data Your program should never use hard-coded path, and actually I think the majority here is not using windows. But I also think that the majority o

Re: parse binary file

2012-01-29 Thread Andrea Crotti
On 01/29/2012 07:51 AM, contro opinion wrote: please download the attachment ,and put in c:\test.data Your program should never use hard-coded path, and actually I think the majority here is not using windows. -- http://mail.python.org/mailman/listinfo/python-list

Re: parse binary file

2012-01-29 Thread Steven D'Aprano
On Sun, 29 Jan 2012 13:39:25 +0100, Peter Otten wrote: > contro opinion wrote: > >> please download the attachment ,and put in c:\test.data > > Your data didn't make it through. Since this is a text-only newsgroup, it won't. >> and run the folloeing code: >> >> from struct import unpack >>

Re: parse binary file

2012-01-29 Thread Peter Otten
contro opinion wrote: > please download the attachment ,and put in c:\test.data Your data didn't make it through. > and run the folloeing code: > > from struct import unpack > file_obj = open('c:\\test.data', 'r') Open the file in binary mode to disable CRNL-to-NL translation which will corr

parse binary file

2012-01-28 Thread contro opinion
please download the attachment ,and put in c:\test.data and run the folloeing code: from struct import unpack file_obj = open('c:\\test.data', 'r') day = file_obj.read(40) while day: parsed = list(unpack('LLL', day[:28])) print parsed day = file_obj.read(4