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.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

txtdata-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: txtdata-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 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.1.tar.gz
Algorithm Hash digest
SHA256 6a2e88a63f22b2a18c192e30e2a30fa16db47e77dfa5b2b524d61a38ed47d434
MD5 c28e3b99d3c8034a3b3fbd06000a24f8
BLAKE2b-256 f147e9d2c87a9321a9abccdcf921c0b15fcb7a20174802454a6d3745ad81c439

See more details on using hashes here.

File details

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

File metadata

  • Download URL: txtdata-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc9b972a6a7dfafff33039ca0ac8e522c93b974201ce65e04e0666cb955a971e
MD5 6c5f6c64448bcbb653c443f4d9cf8b8c
BLAKE2b-256 0f6ef2c68d4f09e59421579ce293d04114f4ee2edbad7ed13406cdc4e4f30bea

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