2017-04-17 7 views
1

私はpandas経由でExcelWriterを使用して作成しているファイルをアップロードしようとしています。ここでExcelファイルをDropboxにアップロードしていますか?

は、私がこれまで持っているものです。

output = BytesIO() 
writer = pd.ExcelWriter(output, engine='xlsxwriter') 
df1.to_excel(writer, sheet_name='raw_data', index=False) 
df_totals.to_excel(writer, sheet_name='totals', index=False) 
writer.save() 
output.seek(0) 
dbx.files_upload(output, 'my_path/test.xlsx') 

それがエラーを投げている:私は理解していないので、

TypeError: expected request_binary as binary type, got <class '_io.BytesIO'> 

file_upload方法は、入力としてバイトを取りますか?

答えて

3

the docsのように、files_uploadには、BytesIOオブジェクトではなく、bytesオブジェクトが必要です。

次のように動作するはずです:

dbx.files_upload(output.getvalue(), 'my_path/test.xlsx') 
関連する問題