[Pythonmac-SIG] Line endings and readline()
Chris Barker
cbarker@jps.net
Tue, 05 Sep 2000 10:08:18 -0700
Andrew Watson wrote:
> Is there some easy way of convincing python to change what it expects as the
> end-of-line character, to deal with this sort of crodd-platform problem?
No, and I wish there was.
Your options are to translate the file first (the dos2unix, and unix2dos
utilities also have a mac2unix option), or to read it in as a binary
file, and do your translation in your code:
data = string.split(open(filename,'rb').read(),'\r')
Or something like that.
-Chris
--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------