将Excel文件上传到保管箱? [英] Uploading Excel files to dropbox?

查看:102
本文介绍了将Excel文件上传到保管箱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过熊猫上传使用ExcelWriter创建的文件.

I am trying to upload a file I am creating using ExcelWriter via pandas.

这是我到目前为止所拥有的:

Here is what I have so far:

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方法将字节作为输入,所以我不明白吗?

The file_upload method takes bytes as input so I don't understand?

推荐答案

您可以在

As you can see in the docs, files_upload expects a bytes object, not a BytesIO object.

以下应能工作:

dbx.files_upload(output.getvalue(), 'my_path/test.xlsx')

这篇关于将Excel文件上传到保管箱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆