Reading binary data with the CSV module

Jason Friedman jsf80238 at gmail.com
Sun Nov 29 20:31:30 EST 2020


Using the Box API:
print(source_file.content())
returns
b'First Name,Last Name,Email Address,Company,Position,Connected
On\nPeter,van
(and more data, not pasted here)
Trying to read it via:
with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file:
reader = csv.DictReader(text_file)
for row in reader:
print(row)
Getting this error:
Traceback (most recent call last):
 File "/home/jason/my_box.py", line 278, in <module>
 with io.TextIOWrapper(source_file.content(), encoding='utf-8') as
text_file:
AttributeError: 'bytes' object has no attribute 'readable'


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /