pytn
With the help of pytn you can use your txt file as a json file in a very simple way
pytn stands for - python text notation
Dependencies
- filemod
pip install pytn
Installation and Usage
-
use
pip install pytn -
Make sure that your
pipversion is updatedpip install --upgrade pip. -
Import the package:
import pytn
Updates
-edit_data()-> bug fix
Functions in the module
- First load the data of the file using load_txt method you need to load
data every time you make changes to it as it is using txt as its main source
load_txt(filename)
- extract_keys method helps you extract all the keys from the txt file , and returns them all in the list
extract_keys(data).
- extract_values method helps you extract all the values from the specific keys in sequence from the txt file , and returns them in the list.
extract_keys(data).
- extract_data method helps you extract all the key value pairs from the txt file to dict
extract_data(filename)
- edit_data method helps you edit key's value pair , it takes filename ,key, and a value to change.
edit_data(filename,key,value_to_change)
- remove_data method helps you remove keys and values pair
remove_value(filename,key)
Run Locally
Clone the project
git clone https://github.com/kshitij1235/pytn/tree/main/dist
Install
pip install pytn
List of Functions
| functions | processs| args|
| ----------|---------|-----|
|load_txt|loads the txt data|filename|
|extract_keys|extract key from data|filename|
|extract_values|extract values from data|filename|
|extract_data|Extracts key value pair|filename|
|edit_data|Edit certain key values|filename,key,value_to_change|
|add_data|Help add data to the txt| filename,new key , new value|
|remove_data|remove key value pair|filename,key|
Usage/Examples
way to write your txt
{
settings: active is on
values:244
meta:[23,52,53,work]
unit_test=True
}
Rules :
1) Dont make any sub tree to write your data do it under one tree/{}.
2)dont use ] or [ inside arrays.
4)strictly use : or = when assigning values.
code
from pytn import *
###printing basic dictornary
file="main.txt"
print(extract_data(file)) #printing key value pairs
####extracting keys and values separately
print(extract_keys(file)) #printing the updated key values
print(extract_values(file)) #printing the updated values values
Output
{'settings': 'active is on', 'values': 244, 'meta': [23, 52, 53, 'work'],'unit_test':True}
['settings', 'values', 'meta','unit_test']
['active is on', 244, [23, 52, 53, 'work'],True]
Badges
Authors
Metadata
Release files for pytn 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytn-1.2.tar.gz | 17.1 kB | Without provenance | Details for pytn-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytn-1.2-py3-none-any.whl | Python 3 | none | any | Details for pytn-1.2-py3-none-any.whl |
Total release size: 34.8 kB
Release files / pytn-1.2.tar.gz
| Download URL | pytn-1.2.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3192cbde54542ac3e475cd5a15fd47e5c0eb7d4bfe7b730d711b633de3fe827c
|
|
BLAKE2b-256 checksum How to use checksums |
4c875d6bc86a12dd0b07561e2957f985d7c87d82ab84c38e3b04988d50a09ae0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.31.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / pytn-1.2-py3-none-any.whl
| Download URL | pytn-1.2-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
172cc121c09d2844f2cf07260100c84d5abae70ecf9659cceac5e976a2da9dde
|
|
BLAKE2b-256 checksum How to use checksums |
d776fa095170e617ed94e394b9671dec7b5968c262d7415dd2240087a7d4390f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.31.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for pytn 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.