Prompt Library ⚙️ Technical Build a Data Processing Script from Scratch
GPT-4o ⚙️ Technical Intermediate

Build a Data Processing Script from Scratch

Write a complete data processing script that reads, cleans, transforms, and outputs structured data — with error handling for real-world messy inputs.

👁 4 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Build a Data Processing Script from Scratch

You are a data engineer writing production-quality data processing scripts.

## Task Description

Language: [LANGUAGE]
Input: [INPUT_FORMAT] file(s) from [INPUT_SOURCE]
Output: [OUTPUT_FORMAT] written to [OUTPUT_DESTINATION]
Transformation required: [TRANSFORMATION_DESCRIPTION]
Volume: approximately [RECORD_COUNT] records per run

## Script Requirements

Build a complete script that:

**1. Reads input data**
Handle [INPUT_FORMAT] format correctly, including:
- Encoding issues (UTF-8 with BOM, Latin-1, etc.)
- Large files that don't fit in memory (streaming if [RECORD_COUNT] > 1M)
- Missing or empty files

**2. Validates and cleans**
For [TRANSFORMATION_DESCRIPTION], define validation rules:
- Required fields that must be present
- Type coercions (string → date, string → number)
- Out-of-range value handling
- Duplicate record strategy

**3. Transforms**
Implement [TRANSFORMATION_DESCRIPTION] with:
- Clear function separation (one function = one transformation step)
- Preservation of audit fields (source, processed_at)

**4. Writes output**
Write [OUTPUT_FORMAT] to [OUTPUT_DESTINATION] with:
- Atomic writes (write to temp, then rename)
- Append vs. overwrite logic

**5. Error handling and logging**
- Log invalid records to a separate error file with row number and reason
- Continue processing after individual record failures
- Exit with non-zero code if error rate exceeds [ERROR_THRESHOLD]%

## Complete Script

Write the full implementation.

## Run Instructions

How to invoke this script with sample command-line arguments.

📝 Fill in the blanks

Replace these placeholders with your own content:

[LANGUAGE]
[INPUT_FORMAT]
[INPUT_SOURCE]
[OUTPUT_FORMAT]
[OUTPUT_DESTINATION]
[TRANSFORMATION_DESCRIPTION]
[RECORD_COUNT]
[ERROR_THRESHOLD]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.