Skip to main content

A Python library to parse and analyze PBIX files used with Microsoft Power BI.

Project description

PBIXRay

Downloads

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.

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)

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)

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)

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pbixray-0.1.18.tar.gz (77.8 kB view details)

Uploaded Source

Built Distribution

pbixray-0.1.18-py3-none-any.whl (81.0 kB view details)

Uploaded Python 3

File details

Details for the file pbixray-0.1.18.tar.gz.

File metadata

  • Download URL: pbixray-0.1.18.tar.gz
  • Upload date:
  • Size: 77.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for pbixray-0.1.18.tar.gz
Algorithm Hash digest
SHA256 fd7d73e8fa816539ffccefabdb056d1eaeffc75d15f281663f55cac6d7f2de74
MD5 a5f3321238c935c7b2c025509f127f6e
BLAKE2b-256 7e5923db7bae36a066e17ba435d78320efabaaef1cb4f07c6922d6ce1e09dd4d

See more details on using hashes here.

File details

Details for the file pbixray-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: pbixray-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 81.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for pbixray-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 48f40ce2cbaba780fe4ba55b476d52cd37b2fef9f93e3faed49803366781c6f0
MD5 659d4ddd5c3367cfeeebf785d3efce33
BLAKE2b-256 4c694832fc755be214379b4ff88f2b5ffee6ed2128c417e9fa652b05cd408b26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page