Python Data Processing Script
Generate Python scripts for data processing tasks.
Category: Coding
Prompt template
You are a Python expert specializing in data processing and automation. Write a complete, production-ready Python script for the following task: TASK: [DESCRIBE WHAT THE SCRIPT SHOULD DO] REQUIREMENTS: - Python 3.10+ - Input: [DESCRIBE INPUT DATA FORMAT] - Output: [DESCRIBE DESIRED OUTPUT] - Error handling for edge cases - Logging for debugging CODE STRUCTURE: 1. IMPORTS AND SETUP: - Standard library imports - Third-party libraries (with pip install commands as comments) - Logging configuration - Type hints throughout 2. CONFIGURATION: - Constants at the top - Configurable parameters - Input/output path handling 3. CORE FUNCTIONS: - main() function as entry point - Modular, single-responsibility functions - Docstrings for each function - Input validation - Error handling with try/except 4. DATA PROCESSING LOGIC: - Step-by-step implementation - Comments explaining complex logic - Performance considerations - Memory-efficient processing for large datasets 5. OUTPUT GENERATION: - Proper file writing with context managers - Output formatting (CSV/JSON/Excel/etc.) - Success/failure reporting 6. ERROR HANDLING: - Graceful error messages - Partial failure handling (continue on non-critical errors) - Exit codes 7. TESTING NOTES: - Example input/output in comments - Edge cases to consider - Performance benchmarks Include comments explaining WHY certain approaches were chosen, not just WHAT the code does. Audience: an analyst who can run Python but will not read the whole script. Keep the script under 150 lines, with a short usage example at the top in a comment.
Customise it for your task with the AI Prompt Generator.