XYZ Format
Read and write whitespace-delimited XYZ coordinate tables (molecular or point clouds).
Overview
| Property | Value |
|---|---|
| Format id | xyz |
| Class | XYZIterable |
| Extensions | .xyz |
| Text format | Yes |
| Flat rows | Yes |
| Read | Yes |
| Write | Yes |
| Extra | none (stdlib) |
Record shape
Each data row yields:
{"element": "O", "x": 0.0, "y": 0.0, "z": 0.0}
Optional trailing fields become extra_0, extra_1, …. An optional atom-count header and comment line are skipped on read and written on write.
Usage
from iterable import open_iterable
with open_iterable("molecule.xyz") as source:
for row in source:
print(row["element"], row["x"], row["y"], row["z"])
Error Handling
- Missing dependency: optional libraries raise
ImportErrorwith an install hint (pip install 'iterabledata[<extra>]'when an extra exists). - Write mode: read-only formats raise
WriteNotSupportedErrororValueErrorwhen opened withmode="w". - Bad or unsupported input: may raise
ValueError,OSError, or library-specific errors. - See Troubleshooting for decoding, detection, and engine issues.
See also
- CIF — crystallographic atom sites
- PDB — Protein Data Bank atoms
- Supported formats
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
encoding | str | 'utf-8' | No | Passed via iterableargs. |