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
from grids import Grid
grid = Grid(5,3) # Create an empty 5x3 grid.
print(grid.get_cell(5,3)) # -> ∅ None
print(grid.get_cell(3,1)) # -> ∅ None
grid.update_cell(5,3,'Foo')
grid.update_cell(3,2,'Bar')
print()
print(grid.view())
Will output...
∅
∅
∅ ∅ ∅ ∅ ∅
∅ ∅ 'Bar' ∅ ∅
∅ ∅ ∅ ∅ 'Foo'
Installation
$ pip install pygrids
Grid Usage
Here's how you can use PyGrids.
Using cells
Getting cells
grid.get_cell(<x>, <y>)
Updating cells
grid.update_cell(<x>, <y>, <new_value>)
Overviewing cells
print(grid.view())
Iterating through cells
By Columns
for column in grid.y_by_x():
for cell in column:
print(x)
By Rows
for row in grid.x_by_y():
for cell in row:
print(y)
Saving Grids
You can save your grids by using their built-in save() method.
# 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 Grids from file
You can also load your grids into python by using Grid's static load() method like so.
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.
print(grid.log)
Looks something like
[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, MultiDimensionalArrays support arrays of any shape.
from grids import MultiDimensionalArray
myshape = [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
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.
Metadata
Release files for PyGrids 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyGrids-1.2.1.tar.gz | 4.7 kB | Without provenance | Details for PyGrids-1.2.1.tar.gz |
Release files / PyGrids-1.2.1.tar.gz
| Download URL | PyGrids-1.2.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f62fcf1594d9eeef9e851c2a85fcfe5006d4450665150c95b5c8d93e8ce894c8
|
|
BLAKE2b-256 checksum How to use checksums |
4b67bf54bc2830b5859a7c553c0401f502c64ce45bc385a59a413ddad3fd216a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.5
|
Security for PyGrids 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.