Skip to main content

Python package for CRUD operations on large files in chunks.

Project description

PyPI version License: MIT Downloads

FileChunkCRUD

FileChunkCRUD is a Python tool designed for Create, Read, Update, and Delete operations on files, especially large files that need to be processed in chunks to fit into memory constraints.

Installation

To install FileChunkCRUD, you can use pip:

pip install FileChunkCRUD

Usage

As a Python Module

FileChunkCRUD can be used as a Python module in your scripts for handling large file operations.

Reading File in Chunks

from filechunkcrud import FileHandler

file_path = '/path/to/your/largefile.txt'
file_handler = FileHandler(file_path)

for chunk in file_handler.read_chunks(chunk_size=1024):  # chunk_size in bytes
    print(chunk)  # or process the chunk

Creating a Large File with Generator

def large_file_generator(size):
    for i in range(size):
        yield f"This is line {i} of the large file.\n"

file_handler.create_file(large_file_generator(1000000))  # For example, one million lines

Appending Data to an Existing File with Generator

def additional_data_generator():
    yield "\nMore data...\n"

file_handler.update_file(additional_data_generator())

Deleting a File

file_handler.delete_file()  # Deletes the file at file_path

Features

  • Read: Read large files in manageable chunks.
  • Create: Create new files with content provided by a generator, ideal for large data sets.
  • Update: Append to existing files using a generator for the content.
  • Delete: Remove files from the filesystem.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

This project is licensed under the MIT License.

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

FileChunkCRUD-0.0.5.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

FileChunkCRUD-0.0.5-py3-none-any.whl (4.8 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