Originally made for my University's Department of Computer Science's course Software Methodologies under the sub-module Digital Communications, as part of the coursework in 2017/2018.
This repository contains an implementation of Huffman Coding for .txt files.
I have included the .txt files I have tested my implementation on in the same directory for ease of use, since the script and the files you wish to encode are to be in the same directory for it to work smoothly.
This project was made utilizing Python 3.6 and should work with all 3.X versions.
In addition, please ensure that the following modules are installed:
To encode a file, please:
- Open a console window and navigate to a directory containing huffman.py and the plain text document file you wish to encode using the cd command
- type
python huffman.py e filename.txt
wherefilename.txt
is to be replaced by the name of the file you wish to encode.
A file filename.hc
should appear in the same directory, ready for decoding
To decode a file, please:
- Open a console window and navigate to a directory containing huffman.py and the .hc file you wish to decode located using the cd command. Ensure that the .hc file was in fact created by huffman.py and not some other script.
- type
python huffman.py d filename.hc
wherefilename.hc
is to be replaced by the name of the file you wish to encode.
A file filename decoded.txt
should appear in the directory.