Skip to content

Commit c762c60

Browse files
authored
Readme (#53)
1 parent dae3892 commit c762c60

File tree

1 file changed

+55
-29
lines changed

1 file changed

+55
-29
lines changed

README.md

+55-29
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,50 @@ Will generate a graph of the dependencies between cells in an Excel spreadsheet.
1414

1515
<br clear="right"/>
1616

17+
## Usage
18+
19+
GraphedExcel can be used in three ways:
20+
21+
1. As python CLI tool, installed from PyPi with `pip install graphedexcel`
22+
2. As a Docker container, `ghcr.io/dalager/graphedexcel`, exposing the CLI tool, not requiring any python dependencies being installed.
23+
3. As a Python module used within your own code, by importing the `graphedexcel` module.
24+
25+
### CLI Tool
26+
27+
```bash
28+
# Install it
29+
pip install graphedexcel
30+
# Run it
31+
python -m graphedexcel <path_to_excel_file>
32+
```
33+
34+
See the command line options below.
35+
36+
### Docker
37+
38+
GraphedExcel is published to <https://ghcr.io/dalager/graphedexcel> and can be run with the following command:
39+
40+
```bash
41+
docker run -v $(pwd):/data ghcr.io/dalager/graphedexcel /data/myworkbook.xlsx -o /data/myworkbook.png
42+
```
43+
44+
Where `myworkbook.xlsx` is sitting in the current directory and the output image will be saved as `myworkbook.png`, also in the current directory.
45+
46+
The `-v` flag is used to mount the current directory into the container as `/data/`
47+
48+
For powershell, use `${pwd}` instead of `$(pwd)` to get the current directory.
49+
50+
### Python Module
51+
52+
```python
53+
import graphedexcel as ge
54+
55+
graph,stats = ge.graphbuilder.build_graph_and_stats("Book1.xlsx")
56+
ge.graph_summarizer.print_summary(graph, stats)
57+
ge.graph_visualizer.visualize_dependency_graph(graph)
58+
59+
```
60+
1761
## Definitions
1862

1963
Single-cell references in a formula sitting in cell `A3` like `=A1+A2` is considered a dependency between the node `A3` and the nodes `A2` and `A1`.
@@ -32,34 +76,29 @@ So when a cell, `C1` contains `=SUM(B1:B3)` the graph will look like this:
3276
```mermaid
3377
3478
graph TD
35-
R -->B1
36-
R -->B2
37-
R -->B3
79+
R --> B1
80+
R --> B2
81+
R --> B3
3882
R["B1:B3"]
3983
C1 --> R
4084
4185
C1["C1=SUM(B1:B3)"]
4286
4387
```
4488

45-
## Installation from pypi package
46-
47-
PyPi project: [graphedexcel](https://pypi.org/project/graphedexcel/)
89+
## Build and run from source
4890

49-
```bash
50-
pip install graphedexcel
51-
```
91+
### Prerequisites
5292

53-
## Installation from source
93+
- Python 3.10 or later
94+
- Poetry (<https://python-poetry.org/>)
5495

5596
```bash
56-
57-
python -m venv venv
58-
source venv/bin/activate
59-
pip install -e .
97+
poetry install
98+
poetry run graphedexcel <path_to_excel_file> [options]
6099
```
61100

62-
## Usage
101+
## Using the CLI tool and its varous options
63102

64103
```bash
65104
python -m graphedexcel <path_to_excel_file>
@@ -208,7 +247,7 @@ This will render the graph using the custom settings defined in the JSON file.
208247
Just run pytest in the root folder.
209248

210249
```bash
211-
pytest
250+
poetry run pytest
212251
```
213252

214253
### Bandit Security Tests
@@ -219,16 +258,3 @@ It will report on medium and high severity safety issues.
219258
```bash
220259
poetry run bandit -c pyproject.toml -r . -lll
221260
```
222-
223-
## Run with Docker
224-
225-
If you don't want to install the python dependencies on your machine, you can run the script in a Docker container. The following command will build the Docker image and run the script on the sample `docs/Book1.xlsx` file.
226-
227-
With a powershell terminal:
228-
229-
```powershell
230-
docker build -t graphedexcel .
231-
docker run --rm -v ${pwd}/docs:/app/docs graphedexcel docs/Book1.xlsx -o docs/av.png
232-
```
233-
234-
Image will be saved in the docs folder

0 commit comments

Comments
 (0)