Skip to main content

Ravdec - Lossless Data Compression

Project description

๐Ÿ“ฆ Ravdec - Lossless Data Compression

๐Ÿ”น Overview

Ravdec is a Python module implementing a lossless data compression algorithm designed by Ravin Kumar on September 19, 2016. This algorithm is designed exclusively for textual data, including alphabets, numbers, and symbols. The algorithm offers two modes:

  • When enforced_8char_input=True, the length of input data must be exactly divisible by 8, ensuring a fixed compression ratio of 1.1429.
  • When enforced_8char_input=False, the compression ratio starts at 1.0435 for a 24-character input (minimum required length) and increases with input size, approaching 1.1429 for larger inputs.

๐Ÿ”ง Development Details


๐Ÿ“Š Compression Ratio

โœ… When enforced_8char_input=False

  • Compression ratio starts at 1.0435 for a 24-character input (minimum required length).
  • Gradually increases, reaching 1.14 at 912-character length, and further approaches 1.1429 as input size increases.
  • Ideal for handling variable-length text data while still achieving efficient compression.

๐Ÿš€ When enforced_8char_input=True

  • Original data length must be exactly divisible by 8, ensuring a fixed compression ratio of 1.1429.
  • Much faster, making it suitable for high-speed data compression.
  • Best for real-time systems where data is continuously growing and frequency-based algorithms are time-consuming.

โณ Complexity Analysis

1๏ธโƒฃ enforced_8char_input = True

  • โœ… Time Complexity: O(n)

  • โœ… Fixed Compression Ratio (1.1429)

  • โœ… Ideal for continuously growing data

  • โœ… Direct 7-bit conversion per character

  • โœ… No padding calculations

  • โœ… Optimized for speed

2๏ธโƒฃ enforced_8char_input = False

  • ๐Ÿ“Œ Time Complexity: O(n) (with minor overhead)

  • ๐Ÿ“Œ Compression ratio varies (~1.04 - 1.1429)

  • ๐Ÿ“Œ Needs Padding Overhead

  • โœ… Direct 7-bit conversion per character

  • ๐Ÿ“Œ Padding calculation and storage overhead

  • ๐Ÿ“Œ Slower compared to enforced mode

๐Ÿ“Œ Comparison Table

Mode Time Complexity Compression Ratio Padding Overhead Best Use Case
enforced_8char_input = True O(n) Fixed (1.1429) โŒ No Padding High-speed data streams
enforced_8char_input = False O(n) (with minor overhead) Variable (~1.04 - 1.1429) โœ… Needs Padding General text compression

๐ŸŽฏ Use Cases

  • ๐Ÿ“œ Log File Compression: Reduces storage space while maintaining quick retrieval.
  • โšก High-Speed Data Transmission: Faster processing with enforced_8char_input=True.
  • ๐Ÿ“ˆ Fixed Compression Ratio Scenarios: Ideal for predictable compression requirements.
  • ๐Ÿ“ Data Archiving: Efficient text storage without losing information.
  • โณ Real-Time Compression: enforced_8char_input=True ensures immediate compression without extra calculations.

๐Ÿš€ Features

  • โœ… Fixed compression ratio up to 1.1429 for enforced_8char_input=True.
  • โœ… Supports alphabets, numbers, and symbols.
  • โœ… Optimized for real-time and high-speed data transmission.

๐Ÿ› ๏ธ Functions

๐Ÿ“Œ file_compression(filename, enforced_8char_input=False)

Compresses a text file and saves the compressed data with the .rdc extension.

๐Ÿ“Œ file_decompression(filename, enforced_8char_input=False)

Decompresses a previously compressed .rdc file back to its original form.

๐Ÿ“Œ compression(read_data, enforced_8char_input=False)

Compresses a string using 7-bit storage, returning a compressed string.

๐Ÿ“Œ decompression(compressed_text, enforced_8char_input=False)

Decompresses a compressed string back to its original form.


๐Ÿ“ฅ Installation

Install using pip:

pip install ravdec

or,

pip install git+https://github.com/mr-ravin/ravdec.git

๐Ÿ“Œ Dependencies:

  • Python >= 3.7
  • No additional dependencies required

๐Ÿ”„ Example Usage

โœ Compressing and Decompressing Text

import ravdec

# When enforced_8char_input=True

data = 'Ravdec !'  # Length of data is divisible by 8

# Compress a string with enforced_8char_input=True
compressed_data = ravdec.compression(data, enforced_8char_input=True) # compressed_data is 'ยฅ\x87ยถLยธร!'

# Decompress the string
decompressed_data = ravdec.decompression(compressed_data, enforced_8char_input=True)
print(compressed_data)    # Output: 'ยฅ\x87ยถLยธร!'
print(decompressed_data)  # Output: 'Ravdec !'



# When enforced_8char_input=False (and input data has length >= 24)

data = 'R'*25
# Compress a string with enforced_8char_input=False
compressed_data = ravdec.compression(data) # by default enforced_8char_input=False

# Decompress the string
decompressed_data = ravdec.decompression(compressed_data) # by default enforced_8char_input=False
print(compressed_data)
print(decompressed_data)

๐Ÿ—‚๏ธ Compressing and Decompressing Files

import ravdec

original_filename = "inputfile.txt"
compressed_filename = filename+".rdc"

# Compress a file
ravdec.file_compression(original_filename) # saves compressed data in compressed_filename

# Decompress the previously compressed file
ravdec.file_decompression(compressed_filename) # saves the decompressed data in original_filename (got after removing '.rdc' from compressed_filename)

๐Ÿ“œ Copyright License

Copyright (c) 2016 Ravin Kumar
Website: https://mr-ravin.github.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
files (the โ€œSoftwareโ€), to deal in the Software without restriction, including without limitation the rights to use, copy, 
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 
Software.

THE SOFTWARE IS PROVIDED โ€œAS ISโ€, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Release history Release notifications | RSS feed

This version

3.4

Download files

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

Source Distribution

ravdec-3.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ravdec-3.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ravdec-3.4.tar.gz.

File metadata

  • Download URL: ravdec-3.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for ravdec-3.4.tar.gz
Algorithm Hash digest
SHA256 6d13e077c2fcb9d01a9f721abc662dc5850da20b83d274dccdfb5b6c74c7341b
MD5 6a650121b91ebd12d17cf46b5d66ee4c
BLAKE2b-256 26a96bbe66800c22976777b57a0f328130c8301b2ac36bf7105ffc17ffd29a45

See more details on using hashes here.

File details

Details for the file ravdec-3.4-py3-none-any.whl.

File metadata

  • Download URL: ravdec-3.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for ravdec-3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4356a0e337660ca5098eb5bdde4140322f77b1e4f1d414c2ff5fe39c257f357e
MD5 e69167aba901137adaa3bd61e6ffaec6
BLAKE2b-256 1a1a51bfaa0bc53eba3555ea82f097d20e29dd0093fa0fb11a5ef3c14ba19a19

See more details on using hashes here.

Supported by

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