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:
openpyxlfor reading Excel filesnetworkxfor creating and handling the dependency graphmatplotlibfor graph visualization
Install these libraries using pip:
pip install openpyxl networkx matplotlib
Usage
- Initialize the Graph: Instantiate the
ExcelDependencyGraphclass with the path to the Excel file. - Build the Dependency Graph: Call the
build_dependency_graph()method to parse the file and build the graph. - Visualize the Graph: Use
visualize_graph()to display the dependency graph. - 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.
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9adaef6f71ec78c6d802b6b942b6d021fec9e3a4ab2ae0717c99bae3ff083441
|
|
| MD5 |
6d0a4c136317868c84be89aeacfa361c
|
|
| BLAKE2b-256 |
05bc177bb3b15baa8e3cda8cc912e3ee1a1c5209ae3d7c206f50f00ac2333eea
|
File details
Details for the file excel_dependency_graph-0.1.1-py3-none-any.whl.
File metadata
- Download URL: excel_dependency_graph-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03b4f2d214eb005ed2d90aa50f2559bb9cdba5e3d2992ab0ce45b32112f77fd6
|
|
| MD5 |
820b87a20f9925cd5d4b01c7815121a4
|
|
| BLAKE2b-256 |
5e56729f59dda8ee28d62b00d78b28bc379422d1c24a60409cadf8533b2faecb
|