#601 · File handling · Intermediate · 70 XP · about 12 min
Write filter_rows(source, target, column, minimum) that copies part of the CSV file source into a new CSV file target:
column is a whole number of at least minimum, keeping the rows in their order. A row whose cell in that column is empty is left out.target held before.Read and write with the csv module, so cells that contain commas stay in one piece. Return how many rows you copied, not counting the header.
If results.csv holds:
name,class,marks Asha,12A,88 Ben,12B,54 Cara,12A,91
then filter_rows('results.csv', 'passed.csv', 'marks', 60) returns 2, and passed.csv holds:
name,class,marks Asha,12A,88 Cara,12A,91
column is always one of the header's names.First solves only, ranked by stars and then time.