A beginner-friendly library for simplified file handling in Python.
Project description
📁 Simple File Utils
A lightweight Python library for simplified file handling operations. It provides easy-to-use functions for working with text, CSV, JSON, and binary files.
✨ Features
- Read / Write / Append TXT files
- Read / Write / Append CSV files
- Read / Write JSON files
- Binary file support using pickle
- Utility helpers:
exists()delete()file_size()get_extension()
📦 Installation
pip install simple-file-utils
🚀 Quickstart
import simple_file_utils as sfu
📄 TXT FILE FUNCTIONS
write_txt(file_path, data)
Writes text to a file (overwrites if it exists).
sfu.write_txt("example.txt", "Hello World")
read_txt(file_path)
Reads entire file content as a string.
content = sfu.read_txt("example.txt")
print(content)
readlines_txt(file_path)
Returns file content as a list of lines.
lines = sfu.readlines_txt("example.txt")
print(lines)
append_txt(file_path, data)
Appends text to an existing file.
sfu.append_txt("example.txt", "\nNew line added")
📊 CSV FILE FUNCTIONS
write_csv(file_path, rows)
Writes a list of rows to a CSV file.
rows = [
["Name", "Age"],
["John",18]
]
sfu.write_csv("data.csv", rows)
read_csv(file_path)
Reads CSV file and returns list of rows.
data = sfu.read_csv("data.csv")
print(data)
append_csv(file_path, rows)
Appends rows to an existing CSV file.
sfu.append_csv("data.csv", [["Alex", 22]])
🧾 JSON Functions
write_json(file_path, data)
Writes a dictionary or list to a JSON file.
user = {
"name": "John",
"age": 18
}
sfu.write_json("user.json", user)
read_json(file_path)
Reads JSON file and returns Python object.
data = sfu.read_json("user.json")
print(data)
💾 Binary Functions
write_bin(file_path, data)
Saves a Python object to a binary file.
numbers = [1, 2, 3, 4]
sfu.write_bin("numbers.bin", numbers)
read_bin(file_path)
Loads a Python object from a binary file.
numbers = sfu.read_bin("numbers.bin")
print(numbers)
🛠 Utility Functions
exists(file_path)
Checks if file exists.
print(sfu.exists("example.txt"))
delete(file_path)
Deletes a file.
sfu.delete("example.txt")
file_size(file_path)
Returns file size in bytes.
size = sfu.file_size("data.csv")
print(size)
get_extension(file_path)
Returns file extension in lowercase.
print(sfu.get_extension("data.csv")) # .csv
🎯 Why Use This Library?
- Reduces repetitive file-handling boilerplate
- Beginner-friendly and easy to understand
- Clean and readable function names
- Great for small scripts and learning projects
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
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
File details
Details for the file simple_file_utils-0.1.0.tar.gz.
File metadata
- Download URL: simple_file_utils-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ebbeffe6ee1f78e43013bc055dcbfa1e037c79916f507fbc1a0e5315c572ae8
|
|
| MD5 |
d94917e42eccc14e94cc2c8b63a7de20
|
|
| BLAKE2b-256 |
d8facc83d99d8ce40c6948ae8ebd6ae9cfa6a27fd81cb1562ff6c152bc5a5adc
|
File details
Details for the file simple_file_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simple_file_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa9f95a776b79bed148757c5ada0ca6f4b583e144dd9d1e0f12d03e669a3346
|
|
| MD5 |
6b40a617bda40bb849a288493940ef6d
|
|
| BLAKE2b-256 |
a8cb8a89bd1c5f96761af4385b336c6df79a592a7b6ee21b46e5405dfa4c5bfe
|