Computer Science Canada

Seemingly Random Blank Line Insertsions

Author:  apython1992 [ Thu Feb 03, 2011 4:17 pm ]
Post subject:  Seemingly Random Blank Line Insertsions

Hello, I'm writing some python code that involved writing data to a file. I've done file work before, but this time it seems as though the file has random blank lines inserted into it. However, the blank lines are not really "blanks" at all...there actually is no whitespace! So, when the file is written, there may be for example a spot where this pattern exists:

line1
line2
line3

line4
line5
line6

Yet, when reading this file, this blank line is not even read. It is treated as though there is nothing between lines 3 and 4, and it's really stumped me. Here is my file writing code:
code:

try:
            file_out.write(','.join(str_list[:14]) + ','.join(str_list[14:21]) + ','.join(str_list[21:]))
        except ValueError:
            file_out.write(','.join(str_list[:14]) + ','.join(str_list[14:21]))


Thanks for the help.

Author:  Tony [ Thu Feb 03, 2011 4:27 pm ]
Post subject:  RE:Seemingly Random Blank Line Insertsions

Use a hex viewer application of choice to see what the actual binary is in the text file at that spot.

Author:  apython1992 [ Fri Feb 04, 2011 8:49 am ]
Post subject:  Re: Seemingly Random Blank Line Insertsions

Thanks Tony, I tried working with that and it seems as though this is purely editor related: working with gedit, these "lines" are displayed, whereas in other editors like NotePad, they are not there. A strange issue nonetheless!


: