txtdata


Nametxtdata JSON
Version 0.1.2 PyPI version JSON
download
home_page
Summary
upload_time2024-01-26 15:17:13
maintainer
docs_urlNone
authorrenanmoretto
requires_python>=3.10,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
```python
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;


```
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "txtdata",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "renanmoretto",
    "author_email": "himynameisrenan@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/a5/29/f9eca4f82043917fb328956ead1fd2f9b40deff95da6dfee49c0a9cf0ac7/txtdata-0.1.2.tar.gz",
    "platform": null,
    "description": "# Easy and light manager for basic text data.\n\nTxtData 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.\n\n\n- Simple and intuitive handling of .txt data.\n- Lightweight design for efficient performance.\n- Extensive testing ensuring reliability.\n\n## Installation\n```\npip install txtdata\n```\n\n## Examples\n```python\nfrom txtdata import TxtData\n\n# Creating an empty TxtData instance\ntxt = TxtData()\nprint(txt.empty)  # Output: True\n\n# Creating with a simple dictionary.\ntxt = TxtData({'A': [1,2,3], 'B': ['x','y','z']})\nprint(txt)  \n# Output: [{'A': 1, 'B': 'x'}, {'A': 2, 'B': 'y'}, {'A': 3, 'B': 'z'}]\n\n# Inserting data\ntxt = TxtData()\ntxt.insert({'A': 123, 'B': 'zzz'})  # single data by single dict\ntxt.insert(A=182, C='asdf')  # single data by keyword\ntxt.insert([{'A': None}, {'B': 'zzz', 'C': 'yes'}])  # multiple data by list of dicts\ntxt.insert({'A': [1, 3], 'B': ['yyy', 'www']})  # multiple data by dict of lists\nprint(txt)\n# Output: [\n#     {'A': 123, 'B': 'zzz', 'C': None},\n#     {'A': 182, 'B': None, 'C': 'asdf'},\n#     {'A': None, 'B': None, 'C': None},\n#     {'A': None, 'B': 'zzz', 'C': 'yes'},\n#     {'A': 1, 'B': 'yyy', 'C': None},\n#     {'A': 3, 'B': 'www', 'C': None}\n# ]\n\n# Filtering data\nfiltered_txt = txt.filter(A=182)\nprint(len(filtered_txt))  # Output: 1 (based on data above)\n\n# Delete\ntxt.delete(B=None) # Deletes all data with B equals to None\n\n# Saving\ntxt.save('data.txt', delimiter=';')\n# txt file:\n# A;B;C\n# 123;zzz;\n# 182;;asdf\n# ;;\n# ;zzz;yes\n# 1;yyy;\n# 3;www;\n\n\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c80fc4e39bc5fbaea54fb7d17a65a0348afbbe88610ce9b46a2ca7001611710",
                "md5": "6e684c98f1af0c3bcd07afd3b687d3fe",
                "sha256": "b7160cfe8c732e6f428e4583cf491161056853b23c58add830eb472d2b7dc778"
            },
            "downloads": -1,
            "filename": "txtdata-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e684c98f1af0c3bcd07afd3b687d3fe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 5531,
            "upload_time": "2024-01-26T15:17:11",
            "upload_time_iso_8601": "2024-01-26T15:17:11.694812Z",
            "url": "https://files.pythonhosted.org/packages/7c/80/fc4e39bc5fbaea54fb7d17a65a0348afbbe88610ce9b46a2ca7001611710/txtdata-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a529f9eca4f82043917fb328956ead1fd2f9b40deff95da6dfee49c0a9cf0ac7",
                "md5": "8b757c5d8a8b39c06388611f38e85296",
                "sha256": "3329c46232b490d840a69a02b3ca208f36f2f1709a8548a79291de2d3be81c29"
            },
            "downloads": -1,
            "filename": "txtdata-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8b757c5d8a8b39c06388611f38e85296",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 5051,
            "upload_time": "2024-01-26T15:17:13",
            "upload_time_iso_8601": "2024-01-26T15:17:13.316602Z",
            "url": "https://files.pythonhosted.org/packages/a5/29/f9eca4f82043917fb328956ead1fd2f9b40deff95da6dfee49c0a9cf0ac7/txtdata-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-26 15:17:13",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "txtdata"
}
        
Elapsed time: 0.17474s