File and JSON File Methods.
Project description
File Tools
Includes useful methods for file/json file reading and writing.
Install
python3 -m pip install file-tools
Usage
from file_tools.file import get_file_string, get_file_lines
from file_tools.json_file import import_json, export_json
my_text = get_file_string('text.txt')
my_lines = get_file_lines('text.txt')
my_dict = import_json('example.json')
my_dict['test'] = 1
export_json(data=my_dict, file='example.json')
Methods
- file
- get_file_string
- returns string from file
- Args
- file (string)
- path (string=''), if empty path will be relative of CWD, otherwise will be relative of path, useful with os.path.abspath(file) to get file relative to module
- get_file_lines
- returns list of lines from file
- Args
- file (string)
- path (string=''), if empty path will be relative of CWD, otherwise will be relative of path, useful with os.path.abspath(file) to get file relative to module
- get_file_string
- json_file
- import_json
- returns dict object (or list) from file
- Args
- file (string)
- path (string=''), if empty path will be relative of CWD, otherwise will be relative of path, useful with os.path.abspath(file) to get file relative to module
- export_json
- exports dict object (or list) to file
- Args
- data (dict or list)
- file (string)
- indent (int) - number of spaces for json file indentation
- path (string=''), if empty path will be relative of CWD, otherwise will be relative of path, useful with os.path.abspath(file) to get file relative to module
- import_json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
file-tools-0.1.3.tar.gz
(2.1 kB
view hashes)
Built Distribution
Close
Hashes for file_tools-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a2ed69ef8587f58f9fd8625cb9353d2a17860b29b69341a7fb889dba795f840 |
|
MD5 | 11e6f6ffbc21decf480fd90943685c6c |
|
BLAKE2b-256 | 0825c35c5a915c748faac9b1a1d8237b305e41dc416fe5fa4d6b834014923d96 |