Skip to main content

A library to parse Excel formulas and create a dependency graph for cells.

Project description

Excel Dependency Graph

Installation

You can install the package from PyPI using the following command:

pip install excel-dependency-graph==0.1.0

Overview

This Python script reads an Excel file and builds a dependency graph of cell formulas using the networkx library. Each cell that contains a formula referencing other cells is represented as a directed graph node, with edges representing the dependencies. The dependency graph can be visualized and analyzed to understand how different cells are interrelated.

Features

  • Parses formulas in Excel sheets to identify cell dependencies.
  • Builds a directed dependency graph using networkx.
  • Visualizes the dependency graph with matplotlib.
  • Allows retrieval of dependencies and dependents of specific cells.
  • Saves the dependency graph in GML format.

Requirements

This script requires the following Python libraries:

  • openpyxl for reading Excel files
  • networkx for creating and handling the dependency graph
  • matplotlib for graph visualization

Install these libraries using pip:

pip install openpyxl networkx matplotlib

Usage

  1. Initialize the Graph: Instantiate the ExcelDependencyGraph class with the path to the Excel file.
  2. Build the Dependency Graph: Call the build_dependency_graph() method to parse the file and build the graph.
  3. Visualize the Graph: Use visualize_graph() to display the dependency graph.
  4. Retrieve Dependencies and Dependents:
    • get_dependencies(cell) returns cells a given cell depends on.
    • get_dependents(cell) returns cells that depend on a given cell.
  5. Save the Graph: Save the graph structure in GML format using save_graph(output_path).

Example usage

graph = ExcelDependencyGraph("example/example.xlsx")
graph.build_dependency_graph()
graph.visualize_graph()
print(graph.get_dependencies("Sheet1!A1"))
print(graph.get_dependents("Sheet1!A1"))
graph.save_graph("dependency_graph.gml")

Sample Output

image

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

excel_dependency_graph-0.1.1.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

excel_dependency_graph-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file excel_dependency_graph-0.1.1.tar.gz.

File metadata

  • Download URL: excel_dependency_graph-0.1.1.tar.gz
  • Upload date:
  • Size: 75.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.5

File hashes

Hashes for excel_dependency_graph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9adaef6f71ec78c6d802b6b942b6d021fec9e3a4ab2ae0717c99bae3ff083441
MD5 6d0a4c136317868c84be89aeacfa361c
BLAKE2b-256 05bc177bb3b15baa8e3cda8cc912e3ee1a1c5209ae3d7c206f50f00ac2333eea

See more details on using hashes here.

File details

Details for the file excel_dependency_graph-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for excel_dependency_graph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03b4f2d214eb005ed2d90aa50f2559bb9cdba5e3d2992ab0ce45b32112f77fd6
MD5 820b87a20f9925cd5d4b01c7815121a4
BLAKE2b-256 5e56729f59dda8ee28d62b00d78b28bc379422d1c24a60409cadf8533b2faecb

See more details on using hashes here.

Supported by

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