Re: struct unpack newline

2005-05-31 Thread grant
Good point. Hadn't thouhgt of that. Thanks Grant -- http://mail.python.org/mailman/listinfo/python-list

Re: struct unpack newline

2005-05-31 Thread Peter Otten
[EMAIL PROTECTED] wrote: > what concerns me though is that although the file is opened in binary > mode, > "for line.." has a problem reading the file correctly. There is _no_ correct way of splitting a file containing binary data in lines because binary data may contain newline bytes that do not

Re: struct unpack newline

2005-05-30 Thread grant
Hi , Thanks for the tip regarding checking the length of line. I discovered that on the problem record it was short by a few bytes. After changing the read method from "for line in.." to "infile.read(n)" my problem was solved, what concerns me though is that although the file is opened in binary m

Re: struct unpack newline

2005-05-27 Thread Richard Brodie
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > except when line[86:90] contains "carriage-return" "linefeed" > which are valid binary packed values. You probably don't want to be reading binary data a line at a time, if that's what you're doing. -- http://mail.python.org/mailma

Re: struct unpack newline

2005-05-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am pretty new to python and am having a problem > intepreting binary data using struct.unpack. > I am reading a file containing binary packed data > using open with "rb". All the values are coming through > fine when using (integer1,) = struct.unpack('l', line[86:90])

struct unpack newline

2005-05-27 Thread grant
Hi All, I am pretty new to python and am having a problem intepreting binary data using struct.unpack. I am reading a file containing binary packed data using open with "rb". All the values are coming through fine when using (integer1,) = struct.unpack('l', line[86:90]) except when line[86:90] con