- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们的 parquet 文件存储在 aws S3 存储桶中,并由 SNAPPY 压缩。我能够使用 python fastparquet 模块读取未压缩版本的 Parquet 文件,但不能读取压缩版本。
这是我用于未压缩的代码
s3 = s3fs.S3FileSystem(key='XESF', secret='dsfkljsf')
myopen = s3.open
pf = ParquetFile('sample/py_test_snappy/part-r-12423423942834.parquet', open_with=myopen)
df=pf.to_pandas()
这不会返回任何错误,但是当我尝试读取文件的活泼压缩版本时:
pf = ParquetFile('sample/py_test_snappy/part-r-12423423942834.snappy.parquet', open_with=myopen)
我在使用 to_pandas() 时出错
df=pf.to_pandas()
错误信息
KeyErrorTraceback (most recent call last) in () ----> 1 df=pf.to_pandas()
/opt/conda/lib/python3.5/site-packages/fastparquet/api.py in to_pandas(self, columns, categories, filters, index) 293 for (name, v) in views.items()} 294 self.read_row_group(rg, columns, categories, infile=f, --> 295 index=index, assign=parts) 296 start += rg.num_rows 297 else:
/opt/conda/lib/python3.5/site-packages/fastparquet/api.py in read_row_group(self, rg, columns, categories, infile, index, assign) 151 core.read_row_group( 152 infile, rg, columns, categories, self.helper, self.cats, --> 153 self.selfmade, index=index, assign=assign) 154 if ret: 155 return df
/opt/conda/lib/python3.5/site-packages/fastparquet/core.py in read_row_group(file, rg, columns, categories, schema_helper, cats, selfmade, index, assign) 300 raise RuntimeError('Going with pre-allocation!') 301 read_row_group_arrays(file, rg, columns, categories, schema_helper, --> 302 cats, selfmade, assign=assign) 303 304 for cat in cats:
/opt/conda/lib/python3.5/site-packages/fastparquet/core.py in read_row_group_arrays(file, rg, columns, categories, schema_helper, cats, selfmade, assign) 289 read_col(column, schema_helper, file, use_cat=use, 290 selfmade=selfmade, assign=out[name], --> 291 catdef=out[name+'-catdef'] if use else None) 292 293
/opt/conda/lib/python3.5/site-packages/fastparquet/core.py in read_col(column, schema_helper, infile, use_cat, grab_dict, selfmade, assign, catdef) 196 dic = None 197 if ph.type == parquet_thrift.PageType.DICTIONARY_PAGE: --> 198 dic = np.array(read_dictionary_page(infile, schema_helper, ph, cmd)) 199 ph = read_thrift(infile, parquet_thrift.PageHeader) 200 dic = convert(dic, se)
/opt/conda/lib/python3.5/site-packages/fastparquet/core.py in read_dictionary_page(file_obj, schema_helper, page_header, column_metadata) 152 Consumes data using the plain encoding and returns an array of values. 153 """ --> 154 raw_bytes = _read_page(file_obj, page_header, column_metadata) 155 if column_metadata.type == parquet_thrift.Type.BYTE_ARRAY: 156 # no faster way to read variable-length-strings?
/opt/conda/lib/python3.5/site-packages/fastparquet/core.py in _read_page(file_obj, page_header, column_metadata) 28 """Read the data page from the given file-object and convert it to raw, uncompressed bytes (if necessary).""" 29 raw_bytes = file_obj.read(page_header.compressed_page_size) ---> 30 raw_bytes = decompress_data(raw_bytes, column_metadata.codec) 31 32 assert len(raw_bytes) == page_header.uncompressed_page_size, \
/opt/conda/lib/python3.5/site-packages/fastparquet/compression.py in decompress_data(data, algorithm) 48 def decompress_data(data, algorithm='gzip'): 49 if isinstance(algorithm, int): ---> 50 algorithm = rev_map[algorithm] 51 if algorithm.upper() not in decompressions: 52 raise RuntimeError("Decompression '%s' not available. Options: %s" %
KeyError: 1
最佳答案
该错误可能表明在您的系统上未找到用于解压 SNAPPY 的库 - 尽管错误消息显然可以更清楚!
根据您的系统,以下行可能会为您解决此问题:
conda install python-snappy
或
pip install python-snappy
如果您在 Windows 上,构建链可能无法工作,也许您需要从 here 安装.
关于python - python fastparquet 模块可以读取压缩的 Parquet 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42234944/
是否可以对 parquet 格式执行分布式并发写入? 是否可以在写入拼花文件时读取它们? 如果有并发读/写的方法,我有兴趣了解。 提前感谢您的帮助。 最佳答案 我最终得到了 Parquet 开发人员的
如何从命令行检查 Parquet 文件的内容? 我现在看到的唯一选择是 $ hadoop fs -get my-path local-file $ parquet-tools head local-f
我正在使用基于 Java(1.8) 的应用程序使用库创建 Parquet 文件 org.apache.avro.Schema 和 org.apache.parquet.hadoop.ParquetWr
我已经使用 pyspark 创建了多个 parquet 文件,现在我正在尝试将所有 parquet 文件合并为 1 个。我能够合并这些文件,但是在读取生成的文件时,我遇到了错误。以前有人遇到过这个问题
我创建了一个数据框,如下所示: expanded_1 = pd.DataFrame({"Point": [random.choice(points) for x in range(30000000)]
当我在 R 和 Python 中保存 Parquet 文件(使用 pyarrow)时,我得到一个保存在元数据中的箭头模式字符串。 如何读取元数据?它是 Flatbuffer 编码数据吗?架构的定义在哪
例如,pandas 的 read_csv有一个 chunk_size允许 read_csv 的参数在 CSV 文件上返回一个迭代器,以便我们可以分块读取它。 Parquet 格式以块的形式存储数据,但
我正在尝试运行最新版本的 Parquet 工具,但遇到了一些问题。出于某种原因org.apache.hadoop.conf.Configuration不在阴影的 jar 里。 (我对 v1.6.0 也
我正在使用 Parquet 框架来编写 Parquet 文件。 我使用此构造函数创建了 Parquet 作家- public class ParquetBaseWriter extends Parqu
使用 spark 和钻头,我可以查询本地 Parquet 文件。 presto 是否提供相同的功能? 换句话说,是否可以使用 presto 查询本地 Parquet 文件 - 无需通过 HDFS 或
我有一个加密的 parquet 数据文件,它被读取为一个输入流。我想从此输入流中提取单个 Parquet 记录。有什么办法可以做到这一点吗?在 avro 中,使用 DatumReader 是可能的。我
我知道 Apache Arrow Parquet 可以读取符合规范的 Delta 编码文件,但不能将它们写出。我想知道是否有任何常用的开源 C++/Python 库可以写出符合 Parquet 规范的
背景: DuckDB 允许直接查询 parquet 文件。例如con.execute("从'Hierarchy.parquet'中选择 *) Parquet 允许按列值对文件进行分区。当一个 Parq
有没有办法将一个巨大的 parquet 文件分成较小的文件(使用 Python)?保留所有列并划分行?谢谢 最佳答案 你可以用 dask 来做. import dask.dataframe as dd
我的 Parquet 文件为 800K 行 x 8.7K 列。我将其加载到 dask 数据框中: import dask.dataframe as dd dask_train_df = dd.read
我有数百个用 PyArrow 创建的 Parquet 文件。然而,其中一些文件的字段/列的名称(我们称其为 Orange)与原始列(称其为 Sporange)略有不同,因为其中一个使用了查询的变体。否
我正在尝试在配置单元中创建 Parquet 表。我可以创建它,但是当我运行 analyze table mytable compute statistics 时;我得到这个结果: numfiles=8
我知道 hdfs 会将文件拆分成大约 64mb 的 block 。我们有流式传输的数据,我们可以将它们存储到大文件或中等大小的文件中。列式文件存储的最佳大小是多少?如果我可以将文件存储到最小列为 64
我想使用 Apache 的 parquet-mr 项目通过 Java 以编程方式读取/写入 Parquet 文件。我似乎找不到任何有关如何使用此 API 的文档(除了查看源代码并查看它的使用方式)——
我在 Impala 中移动数据,而不是我的设计,我丢失了一些数据。我需要将数据从 Parquet 表复制回它们原来的非 Parquet 表。最初,开发人员使用脚本中的一个简单的一行来完成此操作。由于我
我是一名优秀的程序员,十分优秀!