etalab / notebooks

🤓 📓 📊
4 stars 4 forks source link

Switch from break to continue #3

Closed AntoineAugusti closed 4 years ago

AntoineAugusti commented 4 years ago

Related code block in the notebook

for child in [x for x in data_path.iterdir() if x.is_dir()]:
    csvs = list(child.glob('*.csv'))
    for csv in csvs:
        table = parse_csv(csv)
        if table:
            table_cols = [x.lower() for x in table.column_names]
            missing_pivot = []
            for pivot in ['id_station', 'id_pdc', 'date_maj']:
                if pivot not in table_cols:
                    missing_pivot.append(pivot)
            if missing_pivot:
                break # THIS LINE
            for row in table.rows:
               # stuff

The current code skips to the next directory when a pivot is missing. It shouldn't move to the next folder, just to the next CSV file. Hence, this PR.

abulte commented 4 years ago

🙈 Good catch! Thanks.

abulte commented 4 years ago

(not merging right now to remind me I have to deploy)