Skip to main content

A Python library quickly store and fetch different types of data.

Project description

GestUniDt

It is a very basic personal project to quickly store and fetch different types of data into csv files

Installation

pip install GestUniDt

Usage

# Import the library
from GestUniDt import Gud 

# Initialize the main class
g = Gud()

# Use the .new('file_name') method to create a new file
# Use the .idCol() method to add an auto-incrementing id column
# Use the .timeCol() method to add a column that will show the time when a row is added
# Use the .textCol() method to add a simple text column
# Use the .dataCol() to add different types of data who'll be serialized
# You can use multiple textCols and dataCols
g.new('log.csv').idCol().timeCol().textCol('source').textCol('type').dataCol('content')

# Use the .load('file_name') to load an existing file
g.load('log.csv')

# Use the .add() method to add a row
# You can use a list with textCols and dataCols values in order
# You can add multiple lists to add multiple rows
g.add(['Main Function', 'Info', 'Starting the program...'], ['Config Function', 'Error', 'File Config Not Found.'])

# You can also use one or multiple dictionaries as parameter to add rows
g.add({'type': 'log', 'content': 'Another log message.'})

# You can add lists in dataCols
g.add(['numbers', [1, 2, 3, 4]])

# You can add dictionaries in dataCols
g.add(['objects', {'name': 'chair', 'code': 'ab123cd'}])


# Use the .get() method to make query-like data fetching
# Use the .where(col, condition) method to filter the rows
# Use the .cols([cols_list]) to get only selected columns
# Use the .last(n) and the .first(n) methods to get the last or the first n columns
# Use the .df() method to get the result as a dataframe
# Use the .values() method to get the result as a list
# Without any other method the .get() method will return all the rows
# You can use multiple .where() methods to add more conditions
# The .where() method accepts "=", "!=", ">", "<", ">=", "<=" conditions

res = g.get().cols(['type', 'content']).toDf()
res = g.get().where('type', '= log').cols(['id', 'type', 'content']).last(2).values()
res = g.get().where('id', '> 2').where('type', '= log').first(2).values()


# Use the .del_() method to delete one or multiple rows with .where() method filtering.
deleted_count = g.del_().where('type', '= log').execute()

# Use the .count() method to get the actual number of rows
current_count = g.count()

# The timeCol time format is '%Y-%m-%d %H:%M:%S.%f' by default
# You can change it with the .timeFormat(str) method just like using .strftime()
g.timeFormat('%Y-%m-%d %H:%M:%S')

# The variable .lastT stores the last row time if exists a timeCol
last_entry_time = g.lastT

# Use the .clear() method to delete every row
g.clear()

# Use the .deleteCsvFile() method to delete the file.
g.deleteCsvFile()

Development status

GestUniDt is a work-in-progress personal project. Suggestions, feature requests, and constructive feedback are highly welcome. Feel free to open an issue or submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gestunidt-1.0.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

GestUniDt-1.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file gestunidt-1.0.2.tar.gz.

File metadata

  • Download URL: gestunidt-1.0.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for gestunidt-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bd89fa30af27b1b7c658200fd6ce54dc4873f7ba87333418b9d120b3d8327dcc
MD5 e5bdd87930b02e27ce6234f72a68aac4
BLAKE2b-256 9e4ff68240f6f7d49fa5a782ba870108ab91802849865da7d11ff25cb8e1ec9b

See more details on using hashes here.

File details

Details for the file GestUniDt-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: GestUniDt-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for GestUniDt-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 111269bd7dba19c909f545af82380869d340547f6b82c78777f142266b6917f9
MD5 77eef850c4daa555876feb40cf1a6273
BLAKE2b-256 00c54e42acb4a56cfe770235a39510a7f4392455ffee1b31c4fd9a51b252d815

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page