An open API service indexing awesome lists of open source software.

https://github.com/your-vo1d/arithmetic-compression


https://github.com/your-vo1d/arithmetic-compression

arithmetic arithmetic-coding compressin compression-algorithm

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

        

# Huffman Encoding and Decoding

This Python script implements Huffman encoding and decoding algorithms. Huffman encoding is a widely used technique for lossless data compression.

## Usage

1. Make sure you have Python installed on your system.
2. Clone this repository or download the `main.py` file.
3. Open a terminal or command prompt.
4. Navigate to the directory containing the `main.py` file.
5. Run the script using the following command:

```
main.py
```

6. Follow the instructions to enter the name of the file you want to encode.
7. The encoded and decoded files will be saved in the `result` directory.

## Description

The script provides two main functions:
- `encode(input_file, encode_file)`: Encodes the contents of the input file using Huffman encoding and writes the encoded data to the specified output file.
- `decode(encode_file, decode_file)`: Decodes the encoded data from the input file and writes the decoded text to the specified output file.

## File Structure

- `main.py`: The main Python script.
- `result`: Directory to store the encoded and decoded files.
- `README.md`: Documentation explaining how to use the script.

## Requirements

- Python 3.x
- The input file to be encoded

## Example

Suppose you have a text file named `input.txt` that you want to encode:

1. Run the script and enter `input.txt` when prompted.
2. The encoded file (`encode.txt`) and the decoded file (`decode.txt`) will be created in the `result` directory.

## Author

This script was written by Your_Vo1d.