How to resolve “iterator should return strings, not bytes”

后端 未结 3 1232
悲&欢浪女
悲&欢浪女 2021-02-03 20:44

I am trying to import a CSV file, using a form to upload the file from the client system. After I have the file, I\'ll take parts of it and populate a model in my app. However,

3条回答
  •  死守一世寂寞
    2021-02-03 21:00

    In python 3, I used:

    import csv
    from io import StringIO
    csvf = StringIO(xls_file.read().decode())
    reader = csv.reader(csvf, delimiter=',')
    

    xls_file being the file got from the POST form. I hope it helps.

提交回复
热议问题