This Python script implements Huffman encoding and decoding algorithms. Huffman encoding is a widely used technique for lossless data compression.
-
Make sure you have Python installed on your system.
-
Clone this repository or download the
main.py
file. -
Open a terminal or command prompt.
-
Navigate to the directory containing the
main.py
file. -
Run the script using the following command:
main.py
-
Follow the instructions to enter the name of the file you want to encode.
-
The encoded and decoded files will be saved in the
result
directory.
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.
main.py
: The main Python script.result
: Directory to store the encoded and decoded files.README.md
: Documentation explaining how to use the script.
- Python 3.x
- The input file to be encoded
Suppose you have a text file named input.txt
that you want to encode:
- Run the script and enter
input.txt
when prompted. - The encoded file (
encode.txt
) and the decoded file (decode.txt
) will be created in theresult
directory.
This script was written by Your_Vo1d.