Skip to main content

File Tools

Build Status PyPI version

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
        • encoding (string='utf-8'), encoding type, defaults to utf-8
    • 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
        • newline (sting='\n'), newline character to parse
        • encoding (string='utf-8'), encoding type, defaults to utf-8
    • write_file_string
      • writes file string to 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
        • text (string=''), string to write
        • encoding (string='utf-8'), encoding type, defaults to utf-8
    • append_file_string
      • appends file string to 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
        • text (string=''), string to write
        • encoding (string='utf-8'), encoding type, defaults to utf-8
    • write_file_lines
      • appends file lines to 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
        • lines (list=[]), lines to write
        • newline (sting='\n'), newline character to separate lines
        • encoding (string='utf-8'), encoding type, defaults to utf-8
    • append_file_lines
      • appends file lines to 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
        • lines (list=[]), lines to write
        • newline (sting='\n'), newline character to separate lines
        • encoding (string='utf-8'), encoding type, defaults to utf-8
  • 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

Metadata

Release files for file-tools 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for file-tools 0.1.7
File Size Uploaded
file-tools-0.1.7.tar.gz 2.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for file-tools 0.1.7
File Interpreter ABI Platform
file_tools-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / file-tools-0.1.7.tar.gz

Download URL file-tools-0.1.7.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fa122e6c113f6058d81350d147b693ae0ca61831affb3389a83a364a0236ad98
BLAKE2b-256 checksum
How to use checksums
d277dfd78e227f45472a8298ebf5997a73de32fba6156ab75c44f9d7bdfd7337
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

Release files / file_tools-0.1.7-py3-none-any.whl

Download URL file_tools-0.1.7-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0863fe1e66d13c51517c77ac4cafa26b7bce78c0db7a74580407bd8f572a957f
BLAKE2b-256 checksum
How to use checksums
bcdc33929e48f5c9d8b3e4212e749be1992699aa796be8dd1d7a8c1b157d25f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page