Skip to main content

🏺 Read/write JSON/TOML/Yaml/txt 🏺

Project description

Example 1: read a file

d1 = fil.read('file.json')   # Any Json
d2 = fil.read('file.toml')   # A dict
d3 = fil.read('file.yaml')   # Any JSON
d4 = fil.read('file.txt')    # A string

# Reading a JSON Line file returns an interator:
for record in fil.read('file.jsonl'):
    print(record)  # A sequence of JSON

Example 2: write to a file

fil.write(d1, 'file.json')  # d1 can be any JSON
fil.write(d2, 'file.toml')  # d2 must be a dict
fil.write(d3, 'file.yaml')  # d3 can be any JSON
fil.write(d4, 'file.txt')   # d4 most be a str

# Write an iterator to a JSON Line file
dicts = ({'key': i} for i in range(10))
fil.write(dicts, 'file.jsonl')

API Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fil-1.4.3.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

fil-1.4.3-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page