Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Seemingly Random Blank Line Insertsions
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
apython1992




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
apython1992




PostPosted: 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!
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: