【问题标题】:Reading feather file from a url in python从python中的url读取羽毛文件
【发布时间】:2021-08-11 08:18:18
【问题描述】:

我正在使用 s3 的 api 网关代理来读取羽毛文件。下面是我使用的最简单的代码形式。

import pandas as pd

s3_data=pd.read_feather('https://<api_gateway>/<bucket_name/data.feather>')

这给出了一个错误 -

   reader = _feather.FeatherReader(source, use_memory_map=memory_map)
  File "pyarrow\_feather.pyx", line 75, in pyarrow._feather.FeatherReader.__cinit__
  File "pyarrow\error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow\error.pxi", line 114, in pyarrow.lib.check_status
OSError: Verification of flatbuffer-encoded Footer failed.

如果我将羽毛文件保存在本地并像下面这样阅读,一切正常。

s3_data=pd.read_feather("file://localhost//C://Users//<Username>//Desktop//data.feather")

我该如何进行这项工作?

【问题讨论】:

    标签: python amazon-web-services amazon-s3 feather


    【解决方案1】:

    也许网关代理需要做一些重定向,导致它失败。我会做这样的事情:

    from s3fs import S3FileSystem
    
    fs = S3FileSystem(anon=True)
    with fs.open("<bucket>/data.feather") as f:
        df = pd.read_feather(f)
    

    s3fs 是 Dask 的一部分。您还可以使用其他类似的图层。

    PS:如果您使用羽毛进行长期数据存储,Apache Arrow 项目建议不要使用它(羽毛的维护者)。您可能应该使用镶木地板。

    【讨论】:

      猜你喜欢
      • 2021-06-12
      • 2019-05-03
      • 1970-01-01
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      • 2021-06-06
      • 1970-01-01
      相关资源
      最近更新 更多