A Python project demonstrating object-oriented programming patterns and data file format conversion using Polars. I'm not trying to do anything fancy here, just learn. branching out into API development and a React front end eventually.
This project was created as a learning exercise to practice and demonstrate various Python programming concepts and patterns. It implements a flexible file converter that can transform data between CSV and Parquet formats as well as an API Back end and eventually a front end. All of the code was written by humans with a little bit of auto complete for good measure. Any AI was used as a teacher only.
- Uses Python's
abcmodule to define abstract interfaces ReadandWritebase classes define contracts for file operations- Forces subclasses to implement specific methods (
_do_read,_do_write,_get_extension)
- Concrete implementations:
CsvRead,ParquetRead,CsvWrite,ParquetWrite - Each subclass provides format-specific logic while sharing common functionality
- Demonstrates the Open/Closed Principle (open for extension, closed for modification)
FileConverter.FORMATSdictionary maps file extensions to appropriate reader/writer classes- Dynamic class instantiation based on file type
- Makes it easy to add new formats without modifying core logic
- Uses
typingmodule for better code documentation and IDE support TypedDictfor structured dictionaries (ConvertFile,ConvertResult)- Type hints for method parameters and return values
- Comprehensive logging throughout the application
- Validates inputs (file existence, format support, empty data)
- Graceful error handling with informative messages
batch_convert()function handles multiple file conversions- Returns detailed results for each operation (success/failure)
- Continues processing even if individual conversions fail
- Uses
pathlib.Pathfor cross-platform file path handling - Automatic directory creation
- Timestamped output files to prevent overwrites
- Uses FastAPI for it's modern design and performance
- File upload endpoint with multipart/form-data
- Integration of your existing FileConverter abstractions into a web API
- SQL query endpoint that handles multiple file formats
- End-to-end tested with both CSV and Parquet
.
├── main.py # Core implementation
├── api.py # API implementation
├── test_main.py # Unit tests
├── pyproject.toml # Project configuration
└── README.md # This file
- Understanding of abstract base classes and interfaces
- Implementing inheritance hierarchies
- Using factory patterns for flexible object creation
- Writing type-safe Python code with type hints
- Implementing comprehensive error handling and logging
- Working with modern data processing libraries (Polars)
- Creating reusable, extensible code architecture
- Path manipulation and file I/O operations
- Managed to implement polars lazy frames
- The difference between HTTP error handling and domain exceptions
- Managed to get my existing abstraction layers working in the API