Read FileMetaData from footer of a single Parquet file. Parameters ---------- where : str (file path) or file-like object memory_map : bool, default False Create memory map when the source is a file path. decryption_properties : FileDecryptionProperties, default Non
(where, memory_map=False, decryption_properties=None,
filesystem=None)
| 2367 | |
| 2368 | |
| 2369 | def read_metadata(where, memory_map=False, decryption_properties=None, |
| 2370 | filesystem=None): |
| 2371 | """ |
| 2372 | Read FileMetaData from footer of a single Parquet file. |
| 2373 | |
| 2374 | Parameters |
| 2375 | ---------- |
| 2376 | where : str (file path) or file-like object |
| 2377 | memory_map : bool, default False |
| 2378 | Create memory map when the source is a file path. |
| 2379 | decryption_properties : FileDecryptionProperties, default None |
| 2380 | Decryption properties for reading encrypted Parquet files. |
| 2381 | filesystem : FileSystem, default None |
| 2382 | If nothing passed, will be inferred based on path. |
| 2383 | Path will try to be found in the local on-disk filesystem otherwise |
| 2384 | it will be parsed as an URI to determine the filesystem. |
| 2385 | |
| 2386 | Returns |
| 2387 | ------- |
| 2388 | metadata : FileMetaData |
| 2389 | The metadata of the Parquet file |
| 2390 | |
| 2391 | Examples |
| 2392 | -------- |
| 2393 | >>> import pyarrow as pa |
| 2394 | >>> import pyarrow.parquet as pq |
| 2395 | >>> table = pa.table({'n_legs': [4, 5, 100], |
| 2396 | ... 'animal': ["Dog", "Brittle stars", "Centipede"]}) |
| 2397 | >>> pq.write_table(table, 'example.parquet') |
| 2398 | |
| 2399 | >>> pq.read_metadata('example.parquet') |
| 2400 | <pyarrow._parquet.FileMetaData object at ...> |
| 2401 | created_by: parquet-cpp-arrow version ... |
| 2402 | num_columns: 2 |
| 2403 | num_rows: 3 |
| 2404 | num_row_groups: 1 |
| 2405 | format_version: 2.6 |
| 2406 | serialized_size: ... |
| 2407 | """ |
| 2408 | filesystem, where = _resolve_filesystem_and_path(where, filesystem) |
| 2409 | file_ctx = nullcontext() |
| 2410 | if filesystem is not None: |
| 2411 | file_ctx = where = filesystem.open_input_file(where) |
| 2412 | |
| 2413 | with file_ctx: |
| 2414 | file = ParquetFile(where, memory_map=memory_map, |
| 2415 | decryption_properties=decryption_properties) |
| 2416 | return file.metadata |
| 2417 | |
| 2418 | |
| 2419 | def read_schema(where, memory_map=False, decryption_properties=None, |
no test coverage detected