title: Dealing with Windows line-endings in Python
body: <p>I've got a 700MB XML file coming from a Windows provider.</p>
  
  <p>As one might expect, the line endings are '\r\n' (or ^M in vi).  What is the most efficient way to deal with this situation aside from getting the supplier to send over '\n' :-)</p>
  
  <ol>
  <li>Use <a href="http://docs.python.org/library/os.html#os.linesep" rel="nofollow noreferrer">os.linesep</a></li>
  <li>Use <a href="http://docs.python.org/library/stdtypes.html#str.rstrip" rel="nofollow noreferrer">rstrip()</a> (requiring opening the file ... which seems crazy)</li>
  <li>Using <a href="http://www.python.org/dev/peps/pep-0278/" rel="nofollow noreferrer">Universal newline support</a> is not standard on my Mac Snow Leopard - so isn't an option.</li>
  </ol>
  
  <p>I'm open to anything that requires Python 2.6+ but it needs to work on Snow Leopard and Ubuntu 9.10 with minimal external requirements.  I don't mind a small performance penalty but I am looking for the standard best way to deal with this.</p>
  
  <p>----edit----</p>
  
  <p>The line endings are in the middle of the tag descriptors, otherwise they wouldn't be such a problem.  I know this is bad form and that they shouldn't be sending this to me, but this is how I have the file and the vendor is mostly incompetent.</p>