diff --git a/linters/autoformat-csv.py b/linters/autoformat-csv.py index da1b6fa..502ed2f 100644 --- a/linters/autoformat-csv.py +++ b/linters/autoformat-csv.py @@ -8,22 +8,22 @@ def main(): for path in FOLDER.glob('*.csv'): with path.open(mode='rt') as f: - reader = DictReader(f, dialect='unix') - rows = list(reader) - + rows = list(DictReader(f, dialect='unix')) rows.sort(key=lambda row: ( row['Start Date'], row['End Date'], row['Subject'])) - + new_rows = [] for row in rows: for key, value in row.items(): row[key] = value.strip() - + if not row['Subject']: + continue + new_rows.append(row) with path.open(mode='wt') as f: writer = DictWriter( - f, fieldnames=rows[0].keys(), dialect='unix', + f, fieldnames=new_rows[0].keys(), dialect='unix', quoting=QUOTE_MINIMAL) writer.writeheader() - writer.writerows(rows) + writer.writerows(new_rows) if __name__ == '__main__':