Python utility which merges .txt files from an input directory into a single combined_output.txt file, while logging progress to the console and a log file.
Files are processed in alphabetical order, so the combined output is identical and the extension check is case-insensitive. Each file's contents are written beneath a separator line, making it easy to see where each original document begins and every file is guaranteed to end with a newline so no two documents ever run together.
A structured logging system prints messages to the console while writing debug logs to a log file and every run ends with a summary. Files which cannot be read or decoded are skipped and counted, and the exit status reflects the outcome. The core behaviors are covered by an automated test suite running in continuous integration on every push and pull request.
Below are instructions for installing and running this application on a Linux machine.
-
Install the above programs
-
Open a terminal
-
Clone this repository:
git clone git@github.com:devbret/txts-to-txt.git -
Navigate to the repo's directory:
cd txts-to-txt -
Place your
.txtfiles into theinputdirectory of this repo -
Run the program:
python3 app.py -
The results will be saved to
combined_output.txtat the root of this repo
The test suite uses pytest and code style is enforced with ruff.
To run everything locally:
-
Install the tools:
pip install pytest ruff -
Run the tests:
pytest -
Check linting and formatting:
ruff check . && ruff format --check .
This project repo is intended to demonstrate an ability to do the following:
-
Combine all
.txtfiles from an input directory into a single.txtfile -
Log progress, debug details, errors and a final processing summary
-
Track how many (1) files are processed, (2) read errors occur and (3) total UTF-8 byte size of combined content
-
Cover core behaviors with an automated test suite which runs in continuous integration
If you have any questions or would like to collaborate, please reach out either on GitHub or via my website.