FileField
のフィールドにユーザがアップロードした.csvファイルのデータを読み込もうとしています。オブジェクトにアクセスするのに問題はありませんが、csv
モジュールでは動作しないようです。ここでは、私がしようとしているものです:object
は私のモデルのインスタンスとuploaded_file
対応するフィールドであるDjango:FileFieldインスタンスを使用してアップロードされたCSVファイルを読み取る
reader = csv.reader(object.uploaded_file.read())
for rows in reader:
...
。
私はこのエラーを取得しています:また
iterator should return strings, not int (did you open the file in text mode?)
、
私はopen()
方法が、whitout成功を使用しようとしました。この件に関する文書はあまりにも曖昧に思えます。
In addition to the listed methods, File exposes the following attributes and methods of its file object: encoding, fileno, flush, isatty, newlines, read, readinto, readline, readlines, seek, softspace, tell, truncate, write, writelines, xreadlines, readable(), writable(), and seekable().
EDIT
私はそれはおそらく、このthreadを示唆している読み取りモードに関係しています知っているが、どのように:でも最悪、私は上記の使用read()
方法で見つけることができる唯一の事はこれですこの場合、モードを変更することはできますか?