View Single Post
Old 05-17-2009, 08:44 AM   #3
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
This bit of python code should work for what you want:

Code:
>>> f = open('test', 'rb+wb')
>>> text = f.read()
>>> text = text.replace('\n\r', '\n')
>>> text = text.replace('\r', ' ')
>>> text = text.replace('\n', '\n\r')
>>> f.seek(0)
>>> f.truncate(0)
>>> f.write(text)
>>> f.close()
\n\r is the standard newline indicator for Windows system. We replace it with \n which is used on Unix systems. This is so we can replace all single occurances of \r with a single space. Then we put the \n's back to \n\r's.
user_none is offline   Reply With Quote