CodingSaves ~45 minutes

Write a data transformation function

Generate a type-safe, well-tested data transformation function for any ETL or mapping task.

The prompt

You are a data engineering expert. Write a [LANGUAGE] function that transforms data from the input format to the output format described below. Requirements: handle null/undefined/missing fields gracefully, validate the input shape and throw a meaningful error if invalid, be pure (no side effects), include type definitions for input and output (TypeScript interfaces, Python TypedDicts, or equivalent), handle edge cases explicitly (empty arrays, zero values, nested nulls), and be well-commented. Also write unit tests covering happy path and all edge cases.

Input data structure: [PASTE EXAMPLE INPUT JSON OR DESCRIBE STRUCTURE]
Desired output structure: [PASTE EXAMPLE OUTPUT JSON OR DESCRIBE STRUCTURE]
Transformation rules: [DESCRIBE ANY NON-OBVIOUS MAPPING RULES]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts