what does 'rb' mean in csv files?
28,346
Solution 1
It means: Read the file in Binary mode.
For a complete list of options view this.
Solution 2
From open() in the Built-in functions documentation:
open(name[, mode[, buffering]])
The most commonly-used values of mode are
'r'
for reading, (...) Thus, when opening a binary file, you should append'b'
to the mode value to open the file in binary mode, which will improve portability.
So this opens the file to read in a binary mode.
Solution 3
The second argument o open()
is the mode
the file will be opened in. 'rb'
is for Read Binary mode. Read more about it here
Related videos on Youtube
Comments
-
evtoh almost 4 years
import csv with open('test.csv','rb') as file: rows = csv.reader(file, delimiter = ',', quotechar = '"') data = [data for data in rows]
This was in Python: reading in a csv file and saving columns as variables. I couldn't comment, but I'm really confused. What does 'rb' mean?
-
lrnzcigQuite a few questions on this, e.g. this one
-