Minio httpresponse |解码到DataFrame或Excel
目标:在内存中创建数据框,或在本地存储文件。
努力解码Excel文件;我可以解码所有其他文件类型。
代码:
from MinioConn import MinioConn
from io import StringIO
import pandas as pd
import os
client = MinioConn().client()
obj = client.get_object('bucket-name', 'dir/file.xls')
print(type(obj))
print(obj.read())
filename = 'temp.xlsx'
new_file = open(filename, 'w')
try:
new_file.write(obj.response) # .content
new_file.close()
df = pd.read_excel(filename)
except:
os.remove(filename)
Trackback:
<class 'urllib3.response.HTTPResponse'>
2\n\x00q\x0b\x00\x00@\x00\x00\x00,@\xfd\x00\n\x00q\x0b\x01\x00\x0f\x00\xc2\x02\x00\x00\xfd\x00\n\x ...
请告诉我是否应该添加其他内容以发布/澄清。
Goal: create either a Dataframe in memory or store file locally.
Struggling to decode Excel files; I can decode all other file types.
Code:
from MinioConn import MinioConn
from io import StringIO
import pandas as pd
import os
client = MinioConn().client()
obj = client.get_object('bucket-name', 'dir/file.xls')
print(type(obj))
print(obj.read())
filename = 'temp.xlsx'
new_file = open(filename, 'w')
try:
new_file.write(obj.response) # .content
new_file.close()
df = pd.read_excel(filename)
except:
os.remove(filename)
Traceback:
<class 'urllib3.response.HTTPResponse'>
2\n\x00q\x0b\x00\x00@\x00\x00\x00,@\xfd\x00\n\x00q\x0b\x01\x00\x0f\x00\xc2\x02\x00\x00\xfd\x00\n\x ...
Please let me know if I should add anything else to post/ clarify.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论