Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grandmoff100/pygrids
Dimensional Data Manipulation and Spreadsheet-like pretty grids.
https://github.com/grandmoff100/pygrids
arrays grids hacktoberfest numpy python spreadsheet
Last synced: 19 days ago
JSON representation
Dimensional Data Manipulation and Spreadsheet-like pretty grids.
- Host: GitHub
- URL: https://github.com/grandmoff100/pygrids
- Owner: GrandMoff100
- Created: 2020-10-03T20:15:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T19:58:37.000Z (almost 2 years ago)
- Last Synced: 2024-11-23T04:15:40.890Z (3 months ago)
- Topics: arrays, grids, hacktoberfest, numpy, python, spreadsheet
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyGrids
## Description
PyGrids is an module for storing and manipulating spreadsheet-like or grid-like information in python.
It also uses numpy to speed up array operations.## Example
```py
from grids import Gridgrid = Grid(5,3) # Create an empty 5x3 grid.
print(grid.get_cell(5,3)) # -> ∅ None
print(grid.get_cell(3,1)) # -> ∅ Nonegrid.update_cell(5,3,'Foo')
grid.update_cell(3,2,'Bar')print()
print(grid.view())
```
Will output...
```py
∅
∅∅ ∅ ∅ ∅ ∅
∅ ∅ 'Bar' ∅ ∅
∅ ∅ ∅ ∅ 'Foo'
```## Installation
```bash
$ pip install pygrids
```## ``Grid`` Usage
Here's how you can use PyGrids.### Using cells
**Getting cells**
```py
grid.get_cell(, )
```**Updating cells**
```py
grid.update_cell(, , )
```**Overviewing cells**
```py
print(grid.view())
```**Iterating through cells**
> By Columns
```py
for column in grid.y_by_x():
for cell in column:
print(x)
```
> By Rows
```py
for row in grid.x_by_y():
for cell in row:
print(y)
```### Saving `Grid`s
You can save your grids by using their built-in ``save()`` method.
```py
# Saves by default to grid1.dat or grid2.dat if that's taken or grid3.dat if grid2.dat it taken, etc.
grid.save()
# Or you can specify a specify a specific filename
grid.save(filename='mygrid.dat')
```### Loading `Grid`s from file
You can also load your grids into python by using `Grid`'s static ``load()`` method like so.
```py
grid = Grid.load('mygrid.dat')
```## ``GridLog``'s
Each grid object tracks when it's methods are used and logs them to it's unique ``GridLog`` object. Let's take a look from out first example, what it's log would look like.
```py
print(grid.log)
```
Looks something like
```py
[GridLog created at [2020-10-21 20:30:11.230139]]:
-> [GET_CELL] (5, 3) at [2020-10-21 20:30:11.230171]
-> [GET_CELL] (3, 1) at [2020-10-21 20:30:11.230233]
-> [UPDATE_CELL] (5, 3, 'Foo') at [2020-10-21 20:30:11.230270]
-> [UPDATE_CELL] (3, 2, 'Bar') at [2020-10-21 20:30:11.230286]
-> [LOG_VIEW] () at [2020-10-21 20:30:11.230401]
```## ``MultiDimensionalArray``'s
Unlike grids, which are constrained to only 2 dimensions, `MultiDimensionalArray`s support arrays of any shape.```py
from grids import MultiDimensionalArraymyshape = [3,2,4,5]
array = MultiDimensionalArray(myshape)
```Keep reading for how to use it
## MultiDimensionalArray Usage
Here's a few example's on how use MultiDimensionalArray's### Updating and Getting Cells
```py
target_coord = [1,2,3,4]array.update_cell(target_coord, 'Foo')
print(array.get_cell(target_coord)) # Foo
```## License
This software is licensed by an MIT License.