Skip to main content

No project description provided

Project description

Easy and light manager for basic text data.

TxtData is a Python library designed for basic handling of data in .txt files. This lightweight library, with less than 400 lines of code, offers an easy-to-use API and includes comprehensive, well-written tests.

  • Simple and intuitive handling of .txt data.
  • Lightweight design for efficient performance.
  • Extensive testing ensuring reliability.

Installation

pip install txtdata

Examples

from txtdata import TxtData

# Creating an empty TxtData instance
txt = TxtData()
print(txt.empty)  # Output: True

# Creating with a simple dictionary.
txt = TxtData({'A': [1,2,3], 'B': ['x','y','z']})
print(txt)  
# Output: [{'A': 1, 'B': 'x'}, {'A': 2, 'B': 'y'}, {'A': 3, 'B': 'z'}]

# Inserting data
txt = TxtData()
txt.insert({'A': 123, 'B': 'zzz'})  # single data by single dict
txt.insert(A=182, C='asdf')  # single data by keyword
txt.insert([{'A': None}, {'B': 'zzz', 'C': 'yes'}])  # multiple data by list of dicts
txt.insert({'A': [1, 3], 'B': ['yyy', 'www']})  # multiple data by dict of lists
print(txt)
# Output: [
#     {'A': 123, 'B': 'zzz', 'C': None},
#     {'A': 182, 'B': None, 'C': 'asdf'},
#     {'A': None, 'B': None, 'C': None},
#     {'A': None, 'B': 'zzz', 'C': 'yes'},
#     {'A': 1, 'B': 'yyy', 'C': None},
#     {'A': 3, 'B': 'www', 'C': None}
# ]

# Filtering data
filtered_txt = txt.filter(A=182)
print(len(filtered_txt))  # Output: 1 (based on data above)

# Delete
txt.delete(B=None) # Deletes all data with B equals to None

# Saving
txt.save('data.txt', delimiter=';')
# txt file:
# A;B;C
# 123;zzz;
# 182;;asdf
# ;;
# ;zzz;yes
# 1;yyy;
# 3;www;

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

txtdata-0.1.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

txtdata-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file txtdata-0.1.2.tar.gz.

File metadata

  • Download URL: txtdata-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for txtdata-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3329c46232b490d840a69a02b3ca208f36f2f1709a8548a79291de2d3be81c29
MD5 8b757c5d8a8b39c06388611f38e85296
BLAKE2b-256 a529f9eca4f82043917fb328956ead1fd2f9b40deff95da6dfee49c0a9cf0ac7

See more details on using hashes here.

File details

Details for the file txtdata-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: txtdata-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for txtdata-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7160cfe8c732e6f428e4583cf491161056853b23c58add830eb472d2b7dc778
MD5 6e684c98f1af0c3bcd07afd3b687d3fe
BLAKE2b-256 7c80fc4e39bc5fbaea54fb7d17a65a0348afbbe88610ce9b46a2ca7001611710

See more details on using hashes here.

Supported by

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