问题描述
我需要打开一个压缩文件,里面有一个镶木地板文件,里面有一些数据。我在尝试打印/读取文件中的内容时遇到了很多麻烦。我尝试了以下方法:
with gzip.open("myFile.parquet.gzip","rb") as f:
data = f.read()
这似乎不起作用,因为出现错误,我的文件ID不是gz文件。谢谢!
解决方法
您可以从read_parquet
模块使用pandas
功能:
- 安装
pandas
和pyarrow
:
pip install pandas pyarrow
- 使用
read_parquet
返回DataFrame
:
data = read_parquet("myFile.parquet.gzip")
print(data.count()) # example of operation on the returned DataFrame