Codington
0 of 6 problems solved • 0%

Exercise prompt

Check Required Columns

Example

Reading a table header does not require a first data row.

import csv from io import StringIO table = csv.DictReader(StringIO("name,zone,fare\n")) print(table.fieldnames) # ['name', 'zone', 'fare'] print(list(table)) # []

Compare the header with the fields a program needs before trying to process any rows.

Your task

Implement missing_columns(text, required). Return the required column names absent from the comma-delimited CSV header, in the order given by required. Compare names exactly. The required list has unique strings. A completely empty text has no column names.

missing_columns("fare,zone\n3,A", ["time", "zone", "name"]) # ["time", "name"]