Odoo 11, uses Python3, which is good, but I wonder what is the best way to read/write to file-like objects.
Code which seemed to work like a charm in Py2.7, failed to execute in Py3, thus I wonder what could I be doing wrong...
I did changed import StringIO from io, but no luck. Anybody faced issues like this, any suggestions would be appreciated.
from io import StringIO
wb = xlwt.Workbook(encoding="UTF-8")
ws = wb.add_sheet('Sheet1')
....
fp = StringIO()
wb.save(fp)
fp.seek(0)
data = fp.read()
fp.close()
Error:
File "/usr/lib/python3.6/zipfile.py", line 1784, in _write_end_record
self.fp.write(endrec)
TypeError: string argument expected, got 'bytes'
Thanks
Working with zipfiles: https://gist.github.com/sehrishnaz/cb6401882bf9bb37b0712eed400619e3