"Josep M. Fontana" <josep.m.font...@gmail.com> wrote

I tried your suggestion of using .split() to get around the problem but I
still cannot move forward.


fileNameCentury = open(r
'/Volumes/DATA/Documents/workspace/GCA/CORPUS_TEXT_LATIN_1/FileNamesYears.txt'
.split('\r'))

You are trying to split the filename not the contents of the file!

Interestingly I get closer to the solution but with a little twist:

['A-01,1374\n', 'A-02,1499\n', 'A-05,1449\n', 'A-06,1374\n', 'A-09,1449\n',
'B-01,1299\n', 'B-02,1299\n', 'B-06,1349\n'...]

That is, now I do get a list but as you can see I get the newline character as part of each one of the strings in the list. This is pretty weird. Is
this a general problem with Macs?

No, this is what you would expect. Reading from a file will give you the \n
character, you can use strip() (or rstrip()) to remove it.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to