excel-dependency-graph


Nameexcel-dependency-graph JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/jiteshgurav/formula-dependency-excel
SummaryA library to parse Excel formulas and create a dependency graph for cells.
upload_time2024-11-11 03:15:04
maintainerNone
docs_urlNone
authorJitesh Gurav
requires_python<4.0,>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Excel Dependency Graph

## Installation

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

```bash
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`:

```bash
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](https://github.com/user-attachments/assets/149da8f0-2b75-480d-bb64-f23e25d7ccd0)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jiteshgurav/formula-dependency-excel",
    "name": "excel-dependency-graph",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Jitesh Gurav",
    "author_email": "jpgurav97@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/05/bc/177bb3b15baa8e3cda8cc912e3ee1a1c5209ae3d7c206f50f00ac2333eea/excel_dependency_graph-0.1.1.tar.gz",
    "platform": null,
    "description": "\n# Excel Dependency Graph\n\n## Installation\n\nYou can install the package from PyPI using the following command:\n\n```bash\npip install excel-dependency-graph==0.1.0\n```\n\n## Overview\n\nThis 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.\n\n## Features\n\n- Parses formulas in Excel sheets to identify cell dependencies.\n- Builds a directed dependency graph using `networkx`.\n- Visualizes the dependency graph with `matplotlib`.\n- Allows retrieval of dependencies and dependents of specific cells.\n- Saves the dependency graph in GML format.\n\n## Requirements\n\nThis script requires the following Python libraries:\n\n- `openpyxl` for reading Excel files\n- `networkx` for creating and handling the dependency graph\n- `matplotlib` for graph visualization\n\nInstall these libraries using `pip`:\n\n```bash\npip install openpyxl networkx matplotlib\n```\n\n## Usage\n\n1. **Initialize the Graph**: Instantiate the `ExcelDependencyGraph` class with the path to the Excel file.\n2. **Build the Dependency Graph**: Call the `build_dependency_graph()` method to parse the file and build the graph.\n3. **Visualize the Graph**: Use `visualize_graph()` to display the dependency graph.\n4. **Retrieve Dependencies and Dependents**:\n   - `get_dependencies(cell)` returns cells a given cell depends on.\n   - `get_dependents(cell)` returns cells that depend on a given cell.\n5. **Save the Graph**: Save the graph structure in GML format using `save_graph(output_path)`.\n\n\n\n# Example usage\n```\ngraph = ExcelDependencyGraph(\"example/example.xlsx\")\ngraph.build_dependency_graph()\ngraph.visualize_graph()\nprint(graph.get_dependencies(\"Sheet1!A1\"))\nprint(graph.get_dependents(\"Sheet1!A1\"))\ngraph.save_graph(\"dependency_graph.gml\")\n```\n\n# Sample Output\n\n![image](https://github.com/user-attachments/assets/149da8f0-2b75-480d-bb64-f23e25d7ccd0)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library to parse Excel formulas and create a dependency graph for cells.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/jiteshgurav/formula-dependency-excel",
        "Repository": "https://github.com/jiteshgurav/formula-dependency-excel"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e56729f59dda8ee28d62b00d78b28bc379422d1c24a60409cadf8533b2faecb",
                "md5": "820b87a20f9925cd5d4b01c7815121a4",
                "sha256": "03b4f2d214eb005ed2d90aa50f2559bb9cdba5e3d2992ab0ce45b32112f77fd6"
            },
            "downloads": -1,
            "filename": "excel_dependency_graph-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "820b87a20f9925cd5d4b01c7815121a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.6",
            "size": 13798,
            "upload_time": "2024-11-11T03:15:02",
            "upload_time_iso_8601": "2024-11-11T03:15:02.472689Z",
            "url": "https://files.pythonhosted.org/packages/5e/56/729f59dda8ee28d62b00d78b28bc379422d1c24a60409cadf8533b2faecb/excel_dependency_graph-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05bc177bb3b15baa8e3cda8cc912e3ee1a1c5209ae3d7c206f50f00ac2333eea",
                "md5": "6d0a4c136317868c84be89aeacfa361c",
                "sha256": "9adaef6f71ec78c6d802b6b942b6d021fec9e3a4ab2ae0717c99bae3ff083441"
            },
            "downloads": -1,
            "filename": "excel_dependency_graph-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6d0a4c136317868c84be89aeacfa361c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.6",
            "size": 75634,
            "upload_time": "2024-11-11T03:15:04",
            "upload_time_iso_8601": "2024-11-11T03:15:04.000321Z",
            "url": "https://files.pythonhosted.org/packages/05/bc/177bb3b15baa8e3cda8cc912e3ee1a1c5209ae3d7c206f50f00ac2333eea/excel_dependency_graph-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-11 03:15:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jiteshgurav",
    "github_project": "formula-dependency-excel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "excel-dependency-graph"
}
        
Elapsed time: 0.92606s