Clean and Standardize Data
Advanced · Write the code · from Build a Simple ETL Pipeline: Extract, Transform, Load
From the lesson: Step 3: Transform - Clean and Standardize
The "T" in ETL is often the most complex step. Transformation includes cleaning (fixing inconsistencies), standardizing (making formats uniform), and enriching (adding derived fields). Let's start with cleaning and standardizing.
Read this part of the lessonWrite a function clean_records(records) that transforms each record:
1. Trim whitespace from name and email.
2. Convert name to title case (e.g., "alice johnson" becomes "Alice Johnson").
3. Convert email to lowercase.
4. Round amount to 2 decimal places.
5. If email is empty, set it to "unknown@placeholder.com".
Return the list of cleaned records. Test with messy data and print the cleaned results.
More ETL Pipeline exercises
- Build the Extraction LayerAdvanced
- Data ValidationAdvanced
- Enrich Records with Derived FieldsAdvanced
- Load Data into SQLiteAdvanced
- Verify and Analyze Loaded DataAdvanced
- The Complete ETLPipeline ClassAdvanced
All Python exercises · 50 practice problems · Practical Projects quiz