json txt
With the help of json txt you can use your txt file as a json file in a very simple way
Dependencies
- re
- filemod
pip install filemod - colored
pip install colored
Installation and Usage
- use
pip install json_txt - Make sure that your
pipversion is updatedpip install --upgrade pip. - Import the package:
import json_txt
Updates
- you no longer need to use brackets to wite values in.
- some bugs are been solved and optimizations are made the library
- now "=" sign can be use in place of ":" is all your choise
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
json_txt.load_txt(filename) -
extract_keys method helps you extract all the keys from the txt file , and returns them all in the list
json_txt.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.
json_txt.extract_keys(data). -
extract_data method helps you extract all the key value pairs from the txt file to dict
json_txt.extract_data(filename) -
edit_data method helps you edit key's value pair , it takes filename ,key, and a value to change.
jason_txt.edit_data(filename,key,value_to_change) -
Helps you detect weather the var is int or not returs bool
json_txt.number_detect(letter) -
Helps you convert text array to the real array eg - "[23,23,353]"-> [23,23,353].
json_txt.generate_array(data)
Run Locally
Clone the project
git clone https://github.com/kshitij1235/Json_txt/tree/main/dist
Install
pip install json_txt
List of Functions
| functions | processs | args |
|---|---|---|
| load_txt | loads the txt data | filename |
| extract_keys | extract key from data | data |
| extract_values | extract values from data | data |
| 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 |
| generate_array | converts string array to real array | data (portion of the aray in string) |
Usage/Examples
way to write your txt
settings: active
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
import json_txt
###printing basic dictornary
file=json_txt.load_txt("main.txt") #load the txt file
print(json_txt.extract_data(file)) #printing key value pairs
####extracting keys and values separately
print(json_txt.extract_keys(file)) #printing the updated key values
print(json_txt.extract_values(file)) #printing the updated values values
Output
✓ Test 1 pass
✓ Test 2 pass
✓ Test 3 pass
All Test Passed
{'settings': 'active', 'values': 244, 'meta': [23, 52, 53, 'work'],'unit_test':True}
['settings', 'values', 'meta','unit_test']
['active', 244, [23, 52, 53, 'work'],True]
Badges
Authors
Metadata
Release files for json-txt 1.4.5
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 |
|---|---|---|---|---|
| json_txt-1.4.5.tar.gz | 5.2 kB | Without provenance | Details for json_txt-1.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_txt-1.4.5-py3-none-any.whl | Python 3 | none | any | Details for json_txt-1.4.5-py3-none-any.whl |
Total release size: 11.1 kB
Release files / json_txt-1.4.5.tar.gz
| Download URL | json_txt-1.4.5.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bc887a1078c38a34837416bfc5c1e1a529639a5e3c1058ea9184c41df1ca348
|
|
BLAKE2b-256 checksum How to use checksums |
fd99821ec9b687c9814c4d656f5082a0830168fb75676ea6a9447d6a19c31e2b
|
| 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / json_txt-1.4.5-py3-none-any.whl
| Download URL | json_txt-1.4.5-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
267d3dbd93190d2f4960400b7ac0c288b7ba8cd5af48aa892fb91792460dc122
|
|
BLAKE2b-256 checksum How to use checksums |
39b9bf27d89c6da97b20a8975dd20eef9a79e340ef57e31c2e6d909f289769e0
|
| 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for json-txt 1.4.5
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.