Mike Hall wrote:
On Mar 23, 2005, at 3:17 AM, Kent Johnson wrote:
Anyway, Mike, it seems clear that your file has line endings in it
which are not consistent with the default for your OS. If reading with
universal newlines doesn't solve the problem, please let us know what
OS you are running und
On Mar 23, 2005, at 3:17 AM, Kent Johnson wrote:
Anyway, Mike, it seems clear that your file has line endings in it
which are not consistent with the default for your OS. If reading with
universal newlines doesn't solve the problem, please let us know what
OS you are running under and give more
On Mar 23, 2005, at 12:53 AM, Alan Gauld wrote:
Typically what happens is you view the file in an application
that autrowraps long lines so it looks like multiple lines on
screen but in fact it is one long line in the file. In that
case Python will only see the single long line.
I'm using subEthaEd
Liam, "rU" worked like a charm. My previous syntax where the lines were condensing was:
fOpen = file(f, "r")
fRead = fTmp.readlines()
In this instance the size of fRead would not correspond to my line numbers. With fOpen = file(f, "rU") it now does. Thanks :)
On Mar 22, 2005, at 7:15 PM, Lia
Liam Clarke wrote:
Oh right, From his email, I got the impression he was getting a list like -
[[abc\rdef\rghi\r]]
We really need a clarification of what is in the original file and what results he is getting. My
impression is that it is mixed line endings so the result of readlines is multiple s
> Unless I'm mistaken .readlines() is supposed to return a list, where
> each index is a line from the file that was handed to it. Well I'm
> finding that it's putting more than one line of my file into a
single
> list entry, and separating them with \r.
\r is the carriage return marker which is
Oh right, From his email, I got the impression he was getting a list like -
[[abc\rdef\rghi\r]]
On Wed, 23 Mar 2005 00:12:12 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Liam Clarke wrote:
> > Worse come to worse, you could always do -
> > x = file(myFile, 'r').read()
> > listX = x.split('
Liam Clarke wrote:
Worse come to worse, you could always do -
x = file(myFile, 'r').read()
listX = x.split('\r')
This will leave the \n in the strings. Reading with universal newlines is a
better solution.
Kent
___
Tutor maillist - Tutor@python.org
ht
>From the docs -
In addition to the standard fopen() values mode may be 'U' or 'rU'.
If Python is built with universal newline support (the default) the
file is opened as a text file, but lines may be terminated by any of
'\n', the Unix end-of-line convention, '\r', the Macintosh convention
or '
Unless I'm mistaken .readlines() is supposed to return a list, where
each index is a line from the file that was handed to it. Well I'm
finding that it's putting more than one line of my file into a single
list entry, and separating them with \r. Surely there's a way to have a
one to one correl
10 matches
Mail list logo