Codington
0 of 6 problems solved • 0%

Exercise prompt

Filter a Ferry Timetable

Example

Some exports separate fields with semicolons. The separator is an option on the reader.

import csv from io import StringIO text = 'city;zone\n"North; Pier";2' row = next(csv.DictReader(StringIO(text), delimiter=";")) print(row["city"]) # North; Pier

Quoting still works with a different delimiter. Once you have the fields you can filter rows by a column.

Your task

Implement open_routes(text) for a semicolon-delimited timetable containing route and status columns. Return the route names from rows whose status is exactly "open", in source order. Column order can vary and quoted fields can contain semicolons.

open_routes("route;status\nPier;open\nLake;closed") # ["Pier"]