With the help of json txt you can use your txt file as a json file in a very simple way

Related tags

JSON python json
Overview

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

Installation and Usage

  1. use pip install json_txt
  2. Make sure that your pip version is updated pip install --upgrade pip.
  3. Select the correct package for your environment:
  4. Import the package: import json_txt

Functions in the module

1)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)

2)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).

3)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).

4)extract_data method helps you extract all the key value pairs from the txt file to dict json_txt.extract_data(filename)

5)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)

6)Helps you detect weather the var is int or not returs bool json_txt.number_detect(letter)

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

Usage/Examples

way to write your txt

{ 
settings:3
x:4
truck:32
}

Rules : 
1) Dont make any sub tree to write your data do it under one tree/{}
2) Dont put dummy values as it wont consider
3) Dont use any numericals in variable name
4)strictly use : 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

#####editing data 
json_txt.edit_data("main.txt","settings",33) #changing value of settings
file=json_txt.load_txt("main.txt")   #again laoding the updated copy
print(json_txt.extract_data(file)) #printing the updated key values

####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

{'settings': 3, 'x': 4, 'truck': 32}
{'settings': 33, 'x': 4, 'truck': 32}
['settings', 'x', 'truck']
[33, 4, 32]

Badges

MIT License

Authors

You might also like...
Json GUI for No Man's Sky save file

NMS-Save-Parser Json GUI for No Man's Sky save file GUI python NMS_SAVE_PARSER.py [optional|save.hg] converter only python convert.py usage: conver

Fileson - JSON File database tools

Fileson is a set of Python scripts to create JSON file databases

Package to Encode/Decode some common file formats to json

ZnJSON Package to Encode/Decode some common file formats to json Available via pip install znjson In comparison to pickle this allows having readable

JsonParser - Parsing the Json file by provide the node name

Json Parser This project is based on Parsing the json and dumping it to CSV via

import json files directly in your python scripts
import json files directly in your python scripts

Install Install from git repository pip install git+https://github.com/zaghaghi/direct-json-import.git Use With the following json in a file named inf

Convert your JSON data to a valid Python object to allow accessing keys with the member access operator(.)

JSONObjectMapper Allows you to transform JSON data into an object whose members can be queried using the member access operator. Unlike json.dumps in

Define your JSON schema as Python dataclasses

Define your JSON schema as Python dataclasses

simplejson is a simple, fast, extensible JSON encoder/decoder for Python

simplejson simplejson is a simple, fast, complete, correct and extensible JSON http://json.org encoder and decoder for Python 3.3+ with legacy suppo

Simple Python Library to convert JSON to XML
Simple Python Library to convert JSON to XML

json2xml Simple Python Library to convert JSON to XML

Owner
Kshitij
Languages known - python , c , cpp, html,css, js
Kshitij
cysimdjson - Very fast Python JSON parsing library

Fast JSON parsing library for Python, 7-12 times faster than standard Python JSON parser.

TeskaLabs 235 Dec 29, 2022
The ldap2json script allows you to extract the whole LDAP content of a Windows domain into a JSON file.

ldap2json The ldap2json script allows you to extract the whole LDAP content of a Windows domain into a JSON file. Features Authenticate with password

Podalirius 68 Dec 7, 2022
Convert your subscriptions csv file into a valid json for Newpipe!

Newpipe-CSV-Fixer Convert your Google subscriptions CSV file into a valid JSON for Newpipe! Thanks to nikcorg for sharing how to convert the CSV into

Juanjo 44 Dec 29, 2022
Creates fake JSON files from a JSON schema

Use jsf along with fake data generators to provide consistent and meaningful fake data for your system.

Andy Challis 86 Jan 3, 2023
Random JSON Key:Pair Json Generator

Random JSON Key:Value Pair Generator This simple script take an engish dictionary of words and and makes random key value pairs. The dictionary has ap

Chris Edwards 1 Oct 14, 2021
Same as json.dumps or json.loads, feapson support feapson.dumps and feapson.loads

Same as json.dumps or json.loads, feapson support feapson.dumps and feapson.loads

boris 5 Dec 1, 2021
Ibmi-json-beautify - Beautify json string with python

Ibmi-json-beautify - Beautify json string with python

Jefferson Vaughn 3 Feb 2, 2022
A python library to convert arbitrary strings representing business opening hours into a JSON format that's easier to use in code

A python library to convert arbitrary strings representing business opening hours into a JSON format that's easier to use in code

Adrian Edwards 9 Dec 2, 2022
This open source Python project allow you to create JSON data trees using Minmup.com

This open source Python project allow you to create JSON data trees using Minmup.com. I try to develop this project all the time. But feel free to use :).

Arttu Väisänen 1 Jan 30, 2022
An tiny CLI to load data from a JSON File during development.

JSON Server - An tiny CLI to load data from a JSON File during development.

Yuvraj.M 4 Mar 22, 2022