Skip to content

michaelkrisper/pyHuffman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyHuffman

A Python script for illustrating the encoding and decoding of data using Huffman coding. This script can handle both text and binary files.

Description

This project is a Python 3 implementation of the Huffman coding algorithm. It includes a script (huffman.py) that can be used to compress and decompress data. The script has been refactored for clarity and now includes comprehensive documentation and a test suite.

Usage

You can run the script from the command line. You can either provide a file as an argument for encoding or run it without arguments to use a default sample text.

With Default Text

To run the script with the default Lorem Ipsum text, simply execute:

python3 huffman.py

With a File

To encode a specific file, provide the file path as a command-line argument:

python3 huffman.py [file_path]

For example, to encode the provided testdata.html:

python3 huffman.py testdata.html

Testing

A test suite is included to verify the functionality of the Huffman coding implementation. The tests cover various scenarios, including simple text, empty strings, and different file types.

To run the tests, execute the following command from the root directory:

python3 -m unittest test_huffman.py

You should see an output indicating that all tests passed successfully.

About

A module for encode/decode of text with Huffman-Coding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors