Sorry for my english. I try create new file in google drive(xlsx) and set someting data. But i have error:
AttributeError: 'bytes' object has no attribute 'encode'
my code:
drive = DriveBox() # return pydrive obj
df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]})
wb = Workbook()
writer = pd.ExcelWriter('', engine='openpyxl')
writer.book = wb
df.to_excel(writer)
xmls = drive.g_drive.CreateFile({'title': 'test.xlsx',
'mimeType': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
xmls.SetContentString(save_virtual_workbook(wb))
xmls.Upload()
UPD:
python vers: 3,6 traceback:
C:\Python36\python.exe C:/work/projects/project/do_api/Main.py
Main
Traceback (most recent call last):
File "C:/work/projects/project/do_api/Main.py", line 18, in <module>
class Main:
File "C:/work/projects/project/do_api/Main.py", line 36, in Main
xmls.log()
File "C:\work\projects\project\do_api\xmsl\XmslBox.py", line 80, in log
xmls.SetContentString(save_virtual_workbook(wb))
File "C:\Python36\lib\site-packages\pydrive\files.py", line 155, in SetContentString
self.content = io.BytesIO(content.encode(encoding))
AttributeError: 'bytes' object has no attribute 'encode'