Build the Extraction Layer
Advanced · Write the code · from Build a Simple ETL Pipeline: Extract, Transform, Load
From the lesson: Step 1: Extract Data from Multiple Sources
The "E" in ETL stands for Extract. In the real world, this means pulling data from databases, APIs, files, and services. Since we can't access real APIs in the browser, we'll simulate multiple data sources using Python data structures - dictionaries for API-like data and multi-line strings for CSV-like data.
Read this part of the lessonCreate two extraction functions:
1. extract_from_api(data) - takes a list of dictionaries, prints "Extracted N records from API", returns the list.
2. extract_from_csv(csv_string) - takes a CSV string, parses it into a list of dicts (converting id to int and amount to float), prints "Extracted N records from CSV", returns the list.
Combine results from both sources into all_records. Print the total count as "Total records: N" and print each record's id and name.
More ETL Pipeline exercises
- Data ValidationAdvanced
- Clean and Standardize DataAdvanced
- 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