https://github.com/rec/fil
🏺 Read/write JSON/TOMLYaml/txt/ 🏺
https://github.com/rec/fil
Last synced: about 1 year ago
JSON representation
🏺 Read/write JSON/TOMLYaml/txt/ 🏺
- Host: GitHub
- URL: https://github.com/rec/fil
- Owner: rec
- Created: 2023-04-29T09:10:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T14:42:33.000Z (over 2 years ago)
- Last Synced: 2024-05-01T19:20:47.444Z (about 2 years ago)
- Language: Python
- Homepage: https://rec.github.io/fil/
- Size: 630 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 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](https://rec.github.io/fil#fil--api-documentation)