Registry / analytics / pbixray

pbixray

JSON →
library0.10.0pypypi✓ verified 84d ago

A Python library to parse and analyze PBIX files used with Microsoft Power BI and Excel PowerPivot. It allows you to extract data models, measures, relationships, Power Query M code, and report metadata from Power BI files. Current version: 0.10.0.

pip install pbixray
INSTALL
IMPORT
SIG · PBIXRAY
P
pbixray
analyticspythonv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PBIXRay
✓ from pbixray import PBIXRay
✗ from pbixray import PBIX
DataMashup
✓ from pbixray import DataMashup
MQuery
✓ from pbixray import MQuery

Load a PBIX file, inspect tables, measures, and relationships.

import os from pbixray import PBIX # Load a PBIX file file_path = os.environ.get('PBIX_PATH', 'path/to/your/file.pbix') if not os.path.exists(file_path): raise FileNotFoundError(f'File not found: {file_path}') pbix = PBIX(file_path) # Access data model tables print(pbix.data_model.tables[0].name) # First table name # Access measures for measure in pbix.data_model.measures: print(measure.name, measure.expression) # Access relationships for rel in pbix.data_model.relationships: print(rel.name, rel.from_table, rel.to_table, rel.from_column, rel.to_column) # Close the PBIX object pbix.close()
Debug
Known issues
gotchaThe PBIX file must be closed with `pbix.close()` to release file handles. Failing to close may cause file locking issues on Windows.
fix
Call `pbix.close()` after processing, or use a context manager (not yet implemented).
affects: all
gotchapbixray only works with PBIX files created by Power BI Desktop. Power BI Service export files (unpacked) are not supported.
fix
Ensure the PBIX file is directly from Power BI Desktop, not from the service.
affects: all
gotchaAccessing `pbix.data_model` may raise an AttributeError if the PBIX file has no data model (e.g., pure report without queries).
fix
Check `hasattr(pbix, 'data_model')` before accessing.
affects: all
deprecatedThe `pbix.report` attribute for parsing report layout (JSON) is experimental and may change in future versions.
fix
Do not rely on the structure of report JSON; use with caution.
affects: <0.11
Upgrade
Version history
0.10.0latest on PyPI · released May 25, 2026
Audit
Dependencies
python-dotenvoptionalFor loading environment variables (optional in quickstart)
Agent activity
87 hits · last 30 days
node
84
OpenAI (training)
1
Resources