A Python library to parse and analyze PBIX files used with Microsoft Power BI and Excel PowerPivot.
Project description
PBIXRay
Overview
PBIXRay is a Python library designed to parse and analyze PBIX files, which are used with Microsoft Power BI. This library provides a straightforward way to extract valuable information from PBIX files, including tables, metadata, Power Query code, and more.
This library is the Python implementation of the logic embedded in the DuckDB extension duckdb-pbix-extension.
Note: PBIXRay also supports Excel (XLSX) files with embedded PowerPivot models. You can use the same API to extract and analyze data models from XLSX files that contain PowerPivot data.
Installation
Before using PBIXRay, ensure you have the following Python modules installed: apsw, kaitaistruct, and pbixray. You can install them using pip:
pip install pbixray
Getting Started
To start using PBIXRay, import the module and initialize it with the path to your PBIX file:
from pbixray import PBIXRay
model = PBIXRay('path/to/your/file.pbix')
Features and Usage
Tables
To list all tables in the model:
tables = model.tables
print(tables)
Metadata
To get metadata about the Power BI configuration used during model creation:
metadata = model.metadata
print(metadata)
Power Query
To display all M/Power Query code used for data transformation, in a dataframe with TableName and Expression columns:
power_query = model.power_query
print(power_query)
M Parameters
To display all M Parameters values in a dataframe with ParameterName, Description, Expression and ModifiedTime columns:
m_parameters = model.m_parameters
print(m_parameters)
Model Size
To find out the model size in bytes:
size = model.size
print(f"Model size: {size} bytes")
DAX Calculated Tables
To view DAX calculated tables in a dataframe with TableName and Expression columns:
dax_tables = model.dax_tables
print(dax_tables)
DAX Measures
To access DAX measures in a dataframe with TableName, Name, Expression, DisplayFolder, and Description columns:
dax_measures = model.dax_measures
print(dax_measures)
Calculated Columns
To access calculated column DAX expressions in a dataframe with TableName,ColumnName and Expression columns:
dax_columns = model.dax_columns
print(dax_columns)
Schema
To get details about the data model schema and column types in a dataframe with TableName, ColumnName, and PandasDataType columns:
schema = model.schema
print(schema)
Relationships
To get the details about the data model relationships in a dataframe with FromTableName, FromColumnName, ToTableName, ToColumnName, IsActive, Cardinality, CrossFilteringBehavior, FromKeyCount, ToKeyCount and RelyOnReferentialIntegrity columns:
relationships = model.relationships
print(relationships)
Row-Level Security (RLS)
To get the details about Row-Level Security roles and permissions in a dataframe with TableName, RoleName, RoleDescription, FilterExpression, State and MetadataPermission columns:
rls = model.rls
print(rls)
Get Table Contents
To retrieve the contents of a specified table:
table_name = 'YourTableName'
table_contents = model.get_table(table_name)
print(table_contents)
Statistics
To get statistics about the model, including column cardinality and byte sizes of dictionary, hash index, and data components, in a dataframe with columns TableName, ColumnName, Cardinality, Dictionary, HashIndex, and DataSize:
statistics = model.statistics
print(statistics)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pbixray-0.5.2.tar.gz.
File metadata
- Download URL: pbixray-0.5.2.tar.gz
- Upload date:
- Size: 40.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
710c8823bed44b1c10ecb921ff122fbeb7223f93924c5f0a3aeefa10812a529f
|
|
| MD5 |
0518eb4fb3076ade4fa195d65cac4cb2
|
|
| BLAKE2b-256 |
427f817a63cb5a27343b17ad961abc318d7f2f0bc7def915895c2345cd231046
|
Provenance
The following attestation bundles were made for pbixray-0.5.2.tar.gz:
Publisher:
publish.yml on Hugoberry/pbixray
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pbixray-0.5.2.tar.gz -
Subject digest:
710c8823bed44b1c10ecb921ff122fbeb7223f93924c5f0a3aeefa10812a529f - Sigstore transparency entry: 1309669081
- Sigstore integration time:
-
Permalink:
Hugoberry/pbixray@97994172968111cec70ca76b76202e6bc806145d -
Branch / Tag:
refs/tags/0.5.2 - Owner: https://github.com/Hugoberry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@97994172968111cec70ca76b76202e6bc806145d -
Trigger Event:
release
-
Statement type:
File details
Details for the file pbixray-0.5.2-py3-none-any.whl.
File metadata
- Download URL: pbixray-0.5.2-py3-none-any.whl
- Upload date:
- Size: 51.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02085e43f838eb4f0ceb7a9bd09137d7083e4619c5f1d0668a9249789148d93c
|
|
| MD5 |
05852e6c283d3cec6937dd7306a74a95
|
|
| BLAKE2b-256 |
23db4cbfb6583671efb645ecc8798ba5ed8f0b3ff06b6412e9d4df88b97fa2fa
|
Provenance
The following attestation bundles were made for pbixray-0.5.2-py3-none-any.whl:
Publisher:
publish.yml on Hugoberry/pbixray
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pbixray-0.5.2-py3-none-any.whl -
Subject digest:
02085e43f838eb4f0ceb7a9bd09137d7083e4619c5f1d0668a9249789148d93c - Sigstore transparency entry: 1309669339
- Sigstore integration time:
-
Permalink:
Hugoberry/pbixray@97994172968111cec70ca76b76202e6bc806145d -
Branch / Tag:
refs/tags/0.5.2 - Owner: https://github.com/Hugoberry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@97994172968111cec70ca76b76202e6bc806145d -
Trigger Event:
release
-
Statement type: