- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将存储在 Azure 存储中的 CSV 文件下载到流中并直接在我的 python 脚本中使用,但是在 Thomas 的帮助下完成此操作后,我无法使用 pandas read_csv 方法,错误消息是:pandas.io .common.EmptyDataError: No columns to parse from file,thus I assume the download CSV stream is actually empty,但在检查存储帐户后,CSV文件没有问题,里面有所有数据,这里有什么问题?以下是 Thomas 的代码:
from azure.storage.blob import BlockBlobService
import io
from io import BytesIO, StringIO
import pandas as pd
from shutil import copyfileobj
with BytesIO() as input_blob:
with BytesIO() as output_blob:
block_blob_service = BlockBlobService(account_name='my account', account_key='mykey')
block_blob_service.get_blob_to_stream('my counter', 'datatest1.csv', input_blob)
df=pd.read_csv(input_blob)
print(df)
copyfileobj(input_blob, output_blob)
#print(output_blob)
# Create the a new blob
block_blob_service.create_blob_from_stream('my counter', 'datatest2.csv', output_blob)
如果我不执行 read_csv 代码,create_blob_from_stream 将创建一个空文件,但如果我执行 read_csv 代码,我会得到错误:
pandas.parser.TextReader.cinit (pandas\parser.c:6171)pandas.io.common.EmptyDataError:没有要从文件中解析的列
the download file stored fine in the blob storage with all data in it. as showing below:
最佳答案
我终于弄明白了,在这上面花了这么多时间!
必须执行:
input_blob.seek(0)
将流保存到 input_blob 后使用流!!
关于python - Azure 存储 get_blob_to_stream 无法将保存的 csv 文件下载为流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49532222/
我的 azure 存储帐户中有一些文件。我需要使用 get_blob_to_stream 下载它们。它返回 azure.storage.blob.models.Blob 对象。所以我无法使用下面的代码
我想将存储在 Azure 存储中的 CSV 文件下载到流中并直接在我的 python 脚本中使用,但是在 Thomas 的帮助下完成此操作后,我无法使用 pandas read_csv 方法,错误消息
我是一名优秀的程序员,十分优秀!