开发者

how to import in csv

开发者 https://www.devze.com 2022-12-21 18:42 出处:网络
I m having a porblem.I m exporting data to an excel in my django admin.The functionality is fine until some special characters are not there.

I m having a porblem.I m exporting data to an excel in my django admin.The functionality is fine until some special characters are not there.

I hav开发者_开发技巧e a text " ACTPrinter ★ Print to iPhone " when i try to export this to an csv file , it gives an error

UnicodeEncodeError at /admin/core/wappubfilter/

'ascii' codec can't encode character u'\u2605' in position 11: ordinal not in range(128)

any idea how to solve it.I tried giving the tring under unicode but not working


you should convert all the data into utf-8. this is done like this:

writer.writerow(
        [unicode(s).encode("utf-8") for s in data]
    )
0

精彩评论

暂无评论...
验证码 换一张
取 消