runtime
200 / 500
question 200 CSV JSON & JSONL · hard

Append new orders to a JSONL log

Every night the shop exports all orders as CSV. The data team keeps an append-only JSONL log of orders and must never get the same order twice. Write the sync step.

Functionsync_orders(csv_path, jsonl_path)
csv_pathCSV order_id,customer_id,status,total; it may list an order more than once (keep the first)
jsonl_paththe log; it may not exist yet, and may contain blank lines
Appendsone line per order whose order_id isn't in the log yet: {"order_id": …, "status": …, "total": <float>}; existing lines are never changed
Returnsthe number of orders appended
Examples
callsync_orders('orders.csv', 'existing.jsonl')returns2
callsync_orders('orders.csv', '_new.jsonl')returns3

Loading your progress…

Append new orders to a JSONL log — Python practice · Runtime