Old python 2.7
contained the code that worked:
import zipfile
import csv
myzip = zipfile.ZipFile('archive.zip')
csv_data = csv.reader(myzip.open('db_file.csv', 'r', 'password'), delimiter=',')
for rowData in csv_data:
...
I need to make it working with python 3.5
.
csv.reader
now requires password as bytes instead of old string -> adding b'password'
and as a result it returns csv_data
also as bytes.
csv.reader
is waiting for a string.
Is there some "elegant" or "out-of-the-box" way to convert bytes to string directly into csv or do I have to iterate over the strings by hands with line.decode('ascii')
for each? (I've used such approach for a simple txt file from the same archive with a password)