Parse Multi-Format Data File with Different Delimiters per Row Type
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A data file contains mixed record types with different delimiters. Each row starts with a type indicator that determines its format and delimiter.

Task

Create a Python script at /home/interview/parse_mixed.py that reads /home/interview/mixed_data.txt, parses rows based on their type indicator and delimiter, and saves each type to separate CSV files: /home/interview/customers.csv, /home/interview/products.csv, and /home/interview/orders.csv.

Output Format

Each output CSV should exclude the type field and include proper headers:

File Columns
customers.csv customer_id, name, email, country
products.csv product_id, name, category, price
orders.csv order_id, customer_id, product_id, quantity, date

Example

Input (mixed_data.txt):

CUSTOMER,C001,John Doe,[email protected],USA
PRODUCT|P001|Laptop|Electronics|999.99
ORDER;O001;C001;P001;2;2026-02-15

Output (customers.csv):

customer_id,name,email,country
C001,John Doe,[email protected],USA

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →