如何使用 Python 将羽毛文件转换为 CSV?

问题描述 投票:0回答:1

如何使用python将feather文件转换为csv文件?

我尝试使用feather模块,pyarrow.feather我只能读取它,但无法将其转换为csv格式。

# when using pandas
import pandas as pd
df = pd.read_feather('coffee_ratings_full.feather')

我收到此错误=>

ArrowInvalid                              Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_26876/2731998856.py in <module>
----> 1 df = pd.read_feather('coffee_ratings_full.feather')

~\Anaconda3\lib\site-packages\pandas\io\feather_format.py in read_feather(path, columns, use_threads, storage_options)
    128     ) as handles:
    129 
--> 130         return feather.read_feather(
    131             handles.handle, columns=columns, use_threads=bool(use_threads)
    132         )

~\Anaconda3\lib\site-packages\pyarrow\feather.py in read_feather(source, columns, use_threads, memory_map, **kwargs)
    224         The contents of the Feather file as a pandas.DataFrame
    225     """
--> 226     return (read_table(
    227         source, columns=columns, memory_map=memory_map,
    228         use_threads=use_threads).to_pandas(use_threads=use_threads, **kwargs))

~\Anaconda3\lib\site-packages\pyarrow\feather.py in read_table(source, columns, memory_map, use_threads)
    250         The contents of the Feather file as a pyarrow.Table
    251     """
--> 252     reader = _feather.FeatherReader(
    253         source, use_memory_map=memory_map, use_threads=use_threads)
    254 

~\Anaconda3\lib\site-packages\pyarrow\_feather.pyx in pyarrow._feather.FeatherReader.__cinit__()

~\Anaconda3\lib\site-packages\pyarrow\error.pxi in pyarrow.lib.pyarrow_internal_check_status()

~\Anaconda3\lib\site-packages\pyarrow\error.pxi in pyarrow.lib.check_status()

ArrowInvalid: File is too small to be a well-formed file
python csv feather
1个回答
0
投票

尽管文件很大,但它仍然比羽毛标题声称的要小。如果写入或下载文件时出现问题,则可能会发生这种情况。从评论来看,这就是本例的问题所在。所以,这不是这段代码,而是最初编写的内容。

© www.soinside.com 2019 - 2024. All rights reserved.