_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)

エラー

エラーメッセージ

 状態:-  閲覧数:955  投稿日:2017-10-28  更新日:2017-10-28  
iteratorはバイトではなく文字列を返す必要があります(テキストモードでファイルを開きましたか?)
[error] _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?), referer:


遭遇例


Python3.6でCSVファイル読込する際、エラー発生

修正前
import csv

csvfile = open('../../data/chp3/data-text.csv', 'rb')
reader = csv.reader(csvfile)


修正後
import csv

csvfile = open('../../data/chp3/data-text.csv', 'r')
reader = csv.reader(csvfile)



SyntaxError: invalid syntax

コメント投稿(ログインが必要)