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