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.3.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.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gestunidt-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 118d243f17b29eaae35eff0e0451ae57374804caf7f88384dea6b2c06e67ac4b
MD5 70e63d090f8b27408ce9b4dd5da87966
BLAKE2b-256 4373a12d614f20f548729137192e45675d53e7dc53ad4c40f2f912a543975439

See more details on using hashes here.

File details

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

File metadata

  • Download URL: GestUniDt-1.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0e687f5980e0923b71ccab7085da604736cdff870de8afb7ef813016d40530d4
MD5 11cf4a2faaa670fe6214872ec05d3a30
BLAKE2b-256 5782a13ca3c2a5c5c3d09cf6907f1ec4c16bc8d66923f9715551c368129776c9

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