0

I am trying to understand opening of a file in different modes; specifically, I don't understand the function of 'rU' in the code below.

csv.reader(open(filename, 'rU'), delimiter=',')

1 Answer 1

1

As per the docs below, the 'U' adds support for universal newline characters as these vary between operating systems.

https://docs.python.org/2/library/functions.html#open

"In addition to the standard fopen() values mode may be 'U' or 'rU'. Python is usually built with universal newlines support; supplying 'U' opens the file as a text file, but lines may be terminated by any of the following: the Unix end-of-line convention '\n', the Macintosh convention '\r', or the Windows convention '\r\n'. All of these external representations are seen as '\n' by the Python program."

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.