A tool to easily read and write json files, pickle files, binary files, csv files and plain text files.
Project description
fies
下の方に日本語の説明があります
Overview
- A tool to easily read and write json files, YAML files, pickle files, binary files, csv files and plain text files.
Usage
import fies
# Save json file
fies["./test.json"] = {"hoge": 23, "dummy_data": "fuga"}
# Read json file
print(fies["./test.json"]) # -> {'hoge': 23, 'dummy_data': 'fuga'}
# Save plain text file
fies["./test.txt"] = "hogehoge"
# Read plain text file
print(fies["./test.txt"]) # -> hogehoge
# Save pickle file
fies["./test.pickle"] = [("hoge", 23), 5.7]
# Read pickle file
print(fies["./test.pickle"]) # -> [('hoge', 23), 5.7]
# Save csv file
fies["./test.csv"] = [
["hoge", "fuga"],
[23, True], # Numbers and bool types will be automatically converted to strings.
['Hey, "Escape" man!\n'] # Any line breaks, commas, or double quotation marks will be automatically escaped.
]
# Save YAML file
fies["./test.yml", "yaml"] = {"hoge": {"fuga": 13, 77: [1,2]}}
# Checking if a file exists
print("test.pickle" in fies) # -> True
print("hoge.txt" in fies["input_dir"]) # -> True
# delete file
del fies["input_dir"]["hoge.txt"]
Advanced usage
# Save binary file
fies["./test.bin", "binary"] = b"hoge"
# format-specified save
fies["./test.myext", "json"] = {"hoge": 23, "dummy_data": "fuga"}
# Recursive Enumeration of Files (Returns a list of absolute paths)
print(fies["./input_dir/"].all())
print(fies["./input_dir/"].rec()) # This notation works the same as above
概要
- jsonファイル, YAMLファイル, pickleファイル, バイナリファイル, csvファイル, プレーンテキストのファイルを簡単に読み書きできるツールです。
使い方
import fies
# jsonファイル保存
fies["./test.json"] = {"hoge": 23, "dummy_data": "fuga"}
# jsonファイル読み込み
print(fies["./test.json"]) # -> {'hoge': 23, 'dummy_data': 'fuga'}
# プレーンテキストファイル書き出し
fies["./test.txt"] = "hogehoge"
# プレーンテキストファイル読み込み
print(fies["./test.txt"]) # -> hogehoge
# pickleファイル書き出し
fies["./test.pickle"] = [("hoge", 23), 5.7]
# pickleファイル読み込み
print(fies["./test.pickle"]) # -> [('hoge', 23), 5.7]
# csvファイル書き出し
fies["./test.csv"] = [
["hoge", "fuga"],
[23, True], # 数値や真理値型のものは文字列に変換される
['Hey, "Escape" man!\n'] # 改行やカンマ、ダブルクオーテーションがある場合は自動的にエスケープされる
]
# yamlファイル書き出し
fies["./test.yml", "yaml"] = {"hoge": {"fuga": 13, 77: [1,2]}}
# ファイルの存在確認
print("test.pickle" in fies) # -> True
print("hoge.txt" in fies["input_dir"]) # -> True
# ファイルの削除
del fies["input_dir"]["hoge.txt"]
発展的な使い方
# バイナリファイル書き出し
fies["./test.bin", "binary"] = b"hoge"
# フォーマット指定書き出し
fies["./test.myext", "json"] = {"hoge": 23, "dummy_data": "fuga"}
# ファイルの再帰的列挙 (絶対パスのリストが返る)
print(fies["./input_dir/"].all())
print(fies["./input_dir/"].rec()) # この書き方でも上記と同様
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
fies-1.6.0.tar.gz
(5.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
fies-1.6.0-py3-none-any.whl
(6.0 kB
view details)
File details
Details for the file fies-1.6.0.tar.gz.
File metadata
- Download URL: fies-1.6.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
466b6597ba37d2e42e53835300acb5c526047cec5dd6280e8c26fda55e2088d4
|
|
| MD5 |
fb043dcf38e0ca693a2acac87dde8ca5
|
|
| BLAKE2b-256 |
e084fc9b5db6823d7780a9b32cc00773a7619311884ef957734bfff2e894e857
|
File details
Details for the file fies-1.6.0-py3-none-any.whl.
File metadata
- Download URL: fies-1.6.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
575f08234b08adf5cf7e87fbb8afed0f318eea2c3b2c47ccda091e598b0ce2cc
|
|
| MD5 |
c88c930aae279b0d86d36dbac81bdab5
|
|
| BLAKE2b-256 |
5693a451db96af1d4a67756dadb909eabe0eb2f2b88849172e4d3daef2817090
|