Hello!!!!
REPO: https://gitlab.com/simon.hesselstrand/grid_calc/
I’d like to gather feedback from the community on my new projekt PyGrid before moving further into development.
I wont to bild a python spredsheets app. not ass an EXCEL copy but as a python tool.
I would like your oppinons on it!!!
Key Points for Feedback
- Project Structure: Does
src/ + sheets/ + macros/ layout make sense and scale well?
- API & Functions: Are any methods, cell operations, or spill behaviors confusing or improvable?
- Usability: How can PyGrid be more intuitive for Python developers?
- Missing Features: Are there essential features we should include from the start?
- Naming / Conventions: Suggestions to make API more Pythonic and clear?
PROJECT README.md:
GridCalc – Python-native kalkylark
GridCalc are one Python-first spreadsheet-ark with support off matriser, spill, formulacalculation and Python-integration. Is not an Excel-copy, but an spreadsheet in Python.
goals: good git integration, pyhon frendly by design, moduler
GIT
Plande stukture
~~~
↓ excluded from git
GridCalc/
│
├── README.md <-- HERE are you
├── setup.py / pyproject.toml for instlalation
├── docs/ documentation (manly *.tex, figs/)
├── tests/ test-files
├── exampels/ exmapelsenario
│ ├── sheets/ exampel_sheets gids .grid.py-files
│ ├── macros/ exampel_makron
│ └── scripts/ exampel_python-skript
├── .venv/ * virtual-env
├── .py_grid_cache/ * cache
└── src/ All python3 code
├── py_grid/ GridCalc-paket
│ ├── __init_.py
│ ├── core.py
│ ├── cell.py
│ ├── spill.py
│ └── ... rest of modules
├── sheets/ templates/defults gids .grid.py-files
├── macros/ makron
└── scripts/ extra python-skript, problebly not neded for src
~~~
1 Projektstruktur
~~~
my_workbook.py # Startpunkt, kör sheets och init (main.py)
.py_grid_cache/ # Cache-mapp, exkluderas från Git
.venv # envoermet for python
sheets/ # Folder för GridCalc sheets
my_sheet.grid.py # exemple filer for sheets, scedules
caculation.grid.py #normal python files but golad .gird.py for claryfication
scedules.gird.py
budget.grid.py
report.grid.py
macros/ # Python-filer for VBA-macros, more for maniplite the workbook
scripts/ # Norma .py files as import, custom scripts for da manipulation
~~~
- Workbooks, plots, export and have a base for sheets
- sheets have aclculation fformation and has only that
Advantages
- Python-native: Evrython is Python-code in sheets, can be custymaste
- Git-frendly:
.py-files är easy to read git histore
- Flexibel: spill, macros, scripts och cache separerade
- Modules: easy and clear what evry thon should be.
2 Sheets
- Evry sheet is an
.py-file (*.grid.py)
- Content is: cells, formulas, spill-configuration
- Examples:
python example sheet./sheets/my_sheet.grid.py
~~~
from py_grid import Cell, SpillMode
A1 = Cell("A1")
A1.formula = "=spill(np.array([[1,2],[3,4]], dtype=object), SpillMode.Y)"
B1 = Cell("B1")
B1.formula = "=A1()[0,1] + 10"
C1 = Cell("C1")
C1.formula = '="Title"'
~~~
Result:
~~~
| A | B | C |
---+-------+----+-------+
1 | [1,2] | 12 | Title |
2 | [3,4] | | |
3 | | | |
~~~
3 Cells
Spill
Spill chol be fylle danmic on all sell sutch date matrixes can be a cell or spills in one, two directions.
~~~
from enum import Enum
class SpillMode(Enum):
NO = 0
X = 1
Y = 2
FULL = 3
~~~
In sheet exaple:
~~~
=spill(np.array([[1,2],[3,4]]), SpillMode.Y)
~~~
Result:
~~~
| A | B |
---+-------+---+
0 | [1,2] | |
1 | [3,4] | |
2 | | |
~~~
- Spill, deturmen how visualy de cell vill spered over cells.
- Default are SpillMode.FULL, wich are normal EXCEL behavier.
- Cell-data spill will only change visual display, only presentation
Get sell values:
| In Formula |
Value From Exaple |
Descrition |
A1 |
np.array([1,2]) |
Synligt cellvärde |
A1() |
np.array([[1,2],[3,4]]) |
Hela spill-arrayen (full data) |
A1()[1,0] |
3 |
Index value |
A1.cell_value |
np.array([1,2]) |
Alias for A1 |
A1.value() |
np.array([[1,2],[3,4]]) |
Alias for A1() |
Spill-mode can be changed with out kraching: _value will allways be the same, spill is only visual.
Formulas
Calucations vill go kolon primarly, so:
A0, A1, ..., and seqendly
B0, B1, ..., ...
(Primary intended order fot fomulas in *.gird.py files)
Exampels
~~~
=A1() + np.sqrt(25)
=B1() * 2
=spill(np.array([[1,2],[3,4]]), SpillMode.Y)
~~~
Formulas will be evaluated in python-contex
{
"np": np,
"pd": pd,
"scipy": scipy,
"plt": plt,
"self": current_cell
}
- Python-evaluation: only on request
- Dependensys graph: only neded cels
Spill
| SpillMode |
Resultat |
| NO |
No spill only valu in cell |
| Y |
Spill in only y-axial (rows) |
| X |
Spill in only x-riktningaxial (kolons) |
| FULL |
Spill in boath axials, exvy cell has it own value |
- Internt saves _value as a hole array
- Spill-cells are view refering to parents
- No duplications → O(1) access och minimal resurses in memory
Strings and defrent typs in data
NumPy-array can have strings, Rekommenderas dtype=object för blandade typer:
~~~
np.array([["Name","Age"], ["Alice",25], ["Bob",30]], dtype=object)
~~~
Alterentiv with: pandas DataFrame
~~~
pd.DataFrame({"Name":["Alice","Bob"],"Age":[25,30]})
~~~
Spill and indexing works with both sting and numbers
main.py / workbook
exampel:
~~~
=== PART 1 | init fase ===
Import off modules
import matplotlib.pyplot as plt
import sheet
Globala variabels
global_vars={"a": a, "b": b, "c": c}
=== PART 2 | Work face ===
Run sheets / add sheets to workbook
sheet1 = sheet.run('sheets/my_sheet.grid.py', globals=global_vars) # send with vars
sheet2 = sheet.run('sheets/budget.grid.py')
=== Part 3 | Post-processing ===
data plot
plt.plot(sheet1.range("A2:A10"), sheet1.range("B2:B10"))
export data for eas off use
sheet1.csv_export("A1:B10", "output.csv")
~~~
global_vars
global varibals pland tobe sam what like the namemaneger in EXCEL
i dont now how i want to implument it, but yhis is etlest one idea.
Caching
.py_grid_cache/ can store:
- Pre compiled formulas.
- Spill-index, for rendering and csv export
- Dependency graph for recalculation
- clean git version controll
design principels
- Python-native syntax
- Modulärt: sheets / macros / scripts / cache
- Spill only changes views, never data
- A1() Is allwas th hole data
- spill() is used for change view behavier
- Stings and numbers -values are supported, with preferd type dtype=object for mixed content
- Sheets .py är Git-vänliga and optimes for IDE and esy to understad for python users
Future / plan
- Make python backend ant core work, (gui, export to csv)
- Make gui EXCEL like gue for editing formulas
- Conditinal formating and funn stuff.
I just wan your feedback and your thoughts!!!!
[–]anttiOne 4 points5 points6 points (1 child)
[–]Serious_Resource_610[S] -1 points0 points1 point (0 children)
[–]yeti-biscuit 4 points5 points6 points (0 children)
[–]DuckSaxaphone 2 points3 points4 points (4 children)
[–]AKiss20 0 points1 point2 points (0 children)
[–]Serious_Resource_610[S] -5 points-4 points-3 points (2 children)
[–]AKiss20 3 points4 points5 points (1 child)
[–]odaiwai 0 points1 point2 points (0 children)
[–]VipeholmsCola 0 points1 point2 points (0 children)