Level Order Traversal

Click here to run this chapter on Colab

More tree traversal

In a previous notebook we wrote two versions of a depth-first search in a tree. Now we are working toward depth-first search, but we’re going to make a stop along the way: level-order traversal.

One application of level-order traversal is searching through directories (aka folders) in a file system. Since directories can contain other directories, which can contains other directories, and so on, we can think of a file system as a tree.

In this notebook, we’ll start by making a tree of directories and fake data files. Then we’ll traverse it several ways.

And while we’re at it, we’ll learn about the os module, which provides functions for interacting with the operating system, especially the file system.

The os module provides mkdir, which creates a directory. It raises an exception if the directory exists, so I’m going to wrap it in a try statement.

import os

def mkdir(dirname):
    try:
        os.mkdir(dirname)
        print('made', dirname)
    except FileExistsError:
        print(dirname, 'exists')

Now I’ll create the directory where we’ll put the fake data.

mkdir('level_data')
level_data exists

Inside level_data, I want to make a subdirectory named 2021. It is tempting to write something like:

year_dir = `level_data/2021`

This path would work on Unix operating systems (including MacOS), but not Windows, which uses \ rather than / between names in a path.

We can avoid this problem by using os.path.join, which joins names in a path with whatever character the operating system wants.

year_dir = os.path.join('level_data', '2021')
mkdir(year_dir)
level_data/2021 exists

To make the fake data files, I’ll use the following function, which opens a file for writing and puts the word data into it.

def make_datafile(dirname, filename):
    filename = os.path.join(dirname, filename)
    open(filename, 'w').write('data\n')
    print('made', filename)

So let’s start by putting a data file in year_dir, imagining that this file contains summary data for the whole year.

make_datafile(year_dir, 'year.csv')
made level_data/2021/year.csv

The following function

  1. Makes a subdirectory that represents one month of the year,

  2. Makes a data file we imagine contains summary data for the month, and

  3. Calls make_day (below) to make subdirectories each day of the month (in a world where all months have 30 days).

def make_month(i, year_dir):
    month = '%.2d' % i
    month_dir = os.path.join(year_dir, month) 
    mkdir(month_dir)
    make_datafile(month_dir, 'month.csv')
    
    for j in range(1, 31):
        make_day(j, month_dir)

make_day makes a sub-subdirectory for a given day of the month, and puts a data file in it.

def make_day(j, month_dir):
    day = '%.2d' % j
    day_dir = os.path.join(month_dir, day) 
    mkdir(day_dir)
    make_datafile(day_dir, 'day.csv')

The following loop makes a directory for each month.

for i in range(1, 13):
    make_month(i, year_dir)
level_data/2021/01 exists
made level_data/2021/01/month.csv
level_data/2021/01/01 exists
made level_data/2021/01/01/day.csv
level_data/2021/01/02 exists
made level_data/2021/01/02/day.csv
level_data/2021/01/03 exists
made level_data/2021/01/03/day.csv
level_data/2021/01/04 exists
made level_data/2021/01/04/day.csv
level_data/2021/01/05 exists
made level_data/2021/01/05/day.csv
level_data/2021/01/06 exists
made level_data/2021/01/06/day.csv
level_data/2021/01/07 exists
made level_data/2021/01/07/day.csv
level_data/2021/01/08 exists
made level_data/2021/01/08/day.csv
level_data/2021/01/09 exists
made level_data/2021/01/09/day.csv
level_data/2021/01/10 exists
made level_data/2021/01/10/day.csv
level_data/2021/01/11 exists
made level_data/2021/01/11/day.csv
level_data/2021/01/12 exists
made level_data/2021/01/12/day.csv
level_data/2021/01/13 exists
made level_data/2021/01/13/day.csv
level_data/2021/01/14 exists
made level_data/2021/01/14/day.csv
level_data/2021/01/15 exists
made level_data/2021/01/15/day.csv
level_data/2021/01/16 exists
made level_data/2021/01/16/day.csv
level_data/2021/01/17 exists
made level_data/2021/01/17/day.csv
level_data/2021/01/18 exists
made level_data/2021/01/18/day.csv
level_data/2021/01/19 exists
made level_data/2021/01/19/day.csv
level_data/2021/01/20 exists
made level_data/2021/01/20/day.csv
level_data/2021/01/21 exists
made level_data/2021/01/21/day.csv
level_data/2021/01/22 exists
made level_data/2021/01/22/day.csv
level_data/2021/01/23 exists
made level_data/2021/01/23/day.csv
level_data/2021/01/24 exists
made level_data/2021/01/24/day.csv
level_data/2021/01/25 exists
made level_data/2021/01/25/day.csv
level_data/2021/01/26 exists
made level_data/2021/01/26/day.csv
level_data/2021/01/27 exists
made level_data/2021/01/27/day.csv
level_data/2021/01/28 exists
made level_data/2021/01/28/day.csv
level_data/2021/01/29 exists
made level_data/2021/01/29/day.csv
level_data/2021/01/30 exists
made level_data/2021/01/30/day.csv
level_data/2021/02 exists
made level_data/2021/02/month.csv
level_data/2021/02/01 exists
made level_data/2021/02/01/day.csv
level_data/2021/02/02 exists
made level_data/2021/02/02/day.csv
level_data/2021/02/03 exists
made level_data/2021/02/03/day.csv
level_data/2021/02/04 exists
made level_data/2021/02/04/day.csv
level_data/2021/02/05 exists
made level_data/2021/02/05/day.csv
level_data/2021/02/06 exists
made level_data/2021/02/06/day.csv
level_data/2021/02/07 exists
made level_data/2021/02/07/day.csv
level_data/2021/02/08 exists
made level_data/2021/02/08/day.csv
level_data/2021/02/09 exists
made level_data/2021/02/09/day.csv
level_data/2021/02/10 exists
made level_data/2021/02/10/day.csv
level_data/2021/02/11 exists
made level_data/2021/02/11/day.csv
level_data/2021/02/12 exists
made level_data/2021/02/12/day.csv
level_data/2021/02/13 exists
made level_data/2021/02/13/day.csv
level_data/2021/02/14 exists
made level_data/2021/02/14/day.csv
level_data/2021/02/15 exists
made level_data/2021/02/15/day.csv
level_data/2021/02/16 exists
made level_data/2021/02/16/day.csv
level_data/2021/02/17 exists
made level_data/2021/02/17/day.csv
level_data/2021/02/18 exists
made level_data/2021/02/18/day.csv
level_data/2021/02/19 exists
made level_data/2021/02/19/day.csv
level_data/2021/02/20 exists
made level_data/2021/02/20/day.csv
level_data/2021/02/21 exists
made level_data/2021/02/21/day.csv
level_data/2021/02/22 exists
made level_data/2021/02/22/day.csv
level_data/2021/02/23 exists
made level_data/2021/02/23/day.csv
level_data/2021/02/24 exists
made level_data/2021/02/24/day.csv
level_data/2021/02/25 exists
made level_data/2021/02/25/day.csv
level_data/2021/02/26 exists
made level_data/2021/02/26/day.csv
level_data/2021/02/27 exists
made level_data/2021/02/27/day.csv
level_data/2021/02/28 exists
made level_data/2021/02/28/day.csv
level_data/2021/02/29 exists
made level_data/2021/02/29/day.csv
level_data/2021/02/30 exists
made level_data/2021/02/30/day.csv
level_data/2021/03 exists
made level_data/2021/03/month.csv
level_data/2021/03/01 exists
made level_data/2021/03/01/day.csv
level_data/2021/03/02 exists
made level_data/2021/03/02/day.csv
level_data/2021/03/03 exists
made level_data/2021/03/03/day.csv
level_data/2021/03/04 exists
made level_data/2021/03/04/day.csv
level_data/2021/03/05 exists
made level_data/2021/03/05/day.csv
level_data/2021/03/06 exists
made level_data/2021/03/06/day.csv
level_data/2021/03/07 exists
made level_data/2021/03/07/day.csv
level_data/2021/03/08 exists
made level_data/2021/03/08/day.csv
level_data/2021/03/09 exists
made level_data/2021/03/09/day.csv
level_data/2021/03/10 exists
made level_data/2021/03/10/day.csv
level_data/2021/03/11 exists
made level_data/2021/03/11/day.csv
level_data/2021/03/12 exists
made level_data/2021/03/12/day.csv
level_data/2021/03/13 exists
made level_data/2021/03/13/day.csv
level_data/2021/03/14 exists
made level_data/2021/03/14/day.csv
level_data/2021/03/15 exists
made level_data/2021/03/15/day.csv
level_data/2021/03/16 exists
made level_data/2021/03/16/day.csv
level_data/2021/03/17 exists
made level_data/2021/03/17/day.csv
level_data/2021/03/18 exists
made level_data/2021/03/18/day.csv
level_data/2021/03/19 exists
made level_data/2021/03/19/day.csv
level_data/2021/03/20 exists
made level_data/2021/03/20/day.csv
level_data/2021/03/21 exists
made level_data/2021/03/21/day.csv
level_data/2021/03/22 exists
made level_data/2021/03/22/day.csv
level_data/2021/03/23 exists
made level_data/2021/03/23/day.csv
level_data/2021/03/24 exists
made level_data/2021/03/24/day.csv
level_data/2021/03/25 exists
made level_data/2021/03/25/day.csv
level_data/2021/03/26 exists
made level_data/2021/03/26/day.csv
level_data/2021/03/27 exists
made level_data/2021/03/27/day.csv
level_data/2021/03/28 exists
made level_data/2021/03/28/day.csv
level_data/2021/03/29 exists
made level_data/2021/03/29/day.csv
level_data/2021/03/30 exists
made level_data/2021/03/30/day.csv
level_data/2021/04 exists
made level_data/2021/04/month.csv
level_data/2021/04/01 exists
made level_data/2021/04/01/day.csv
level_data/2021/04/02 exists
made level_data/2021/04/02/day.csv
level_data/2021/04/03 exists
made level_data/2021/04/03/day.csv
level_data/2021/04/04 exists
made level_data/2021/04/04/day.csv
level_data/2021/04/05 exists
made level_data/2021/04/05/day.csv
level_data/2021/04/06 exists
made level_data/2021/04/06/day.csv
level_data/2021/04/07 exists
made level_data/2021/04/07/day.csv
level_data/2021/04/08 exists
made level_data/2021/04/08/day.csv
level_data/2021/04/09 exists
made level_data/2021/04/09/day.csv
level_data/2021/04/10 exists
made level_data/2021/04/10/day.csv
level_data/2021/04/11 exists
made level_data/2021/04/11/day.csv
level_data/2021/04/12 exists
made level_data/2021/04/12/day.csv
level_data/2021/04/13 exists
made level_data/2021/04/13/day.csv
level_data/2021/04/14 exists
made level_data/2021/04/14/day.csv
level_data/2021/04/15 exists
made level_data/2021/04/15/day.csv
level_data/2021/04/16 exists
made level_data/2021/04/16/day.csv
level_data/2021/04/17 exists
made level_data/2021/04/17/day.csv
level_data/2021/04/18 exists
made level_data/2021/04/18/day.csv
level_data/2021/04/19 exists
made level_data/2021/04/19/day.csv
level_data/2021/04/20 exists
made level_data/2021/04/20/day.csv
level_data/2021/04/21 exists
made level_data/2021/04/21/day.csv
level_data/2021/04/22 exists
made level_data/2021/04/22/day.csv
level_data/2021/04/23 exists
made level_data/2021/04/23/day.csv
level_data/2021/04/24 exists
made level_data/2021/04/24/day.csv
level_data/2021/04/25 exists
made level_data/2021/04/25/day.csv
level_data/2021/04/26 exists
made level_data/2021/04/26/day.csv
level_data/2021/04/27 exists
made level_data/2021/04/27/day.csv
level_data/2021/04/28 exists
made level_data/2021/04/28/day.csv
level_data/2021/04/29 exists
made level_data/2021/04/29/day.csv
level_data/2021/04/30 exists
made level_data/2021/04/30/day.csv
level_data/2021/05 exists
made level_data/2021/05/month.csv
level_data/2021/05/01 exists
made level_data/2021/05/01/day.csv
level_data/2021/05/02 exists
made level_data/2021/05/02/day.csv
level_data/2021/05/03 exists
made level_data/2021/05/03/day.csv
level_data/2021/05/04 exists
made level_data/2021/05/04/day.csv
level_data/2021/05/05 exists
made level_data/2021/05/05/day.csv
level_data/2021/05/06 exists
made level_data/2021/05/06/day.csv
level_data/2021/05/07 exists
made level_data/2021/05/07/day.csv
level_data/2021/05/08 exists
made level_data/2021/05/08/day.csv
level_data/2021/05/09 exists
made level_data/2021/05/09/day.csv
level_data/2021/05/10 exists
made level_data/2021/05/10/day.csv
level_data/2021/05/11 exists
made level_data/2021/05/11/day.csv
level_data/2021/05/12 exists
made level_data/2021/05/12/day.csv
level_data/2021/05/13 exists
made level_data/2021/05/13/day.csv
level_data/2021/05/14 exists
made level_data/2021/05/14/day.csv
level_data/2021/05/15 exists
made level_data/2021/05/15/day.csv
level_data/2021/05/16 exists
made level_data/2021/05/16/day.csv
level_data/2021/05/17 exists
made level_data/2021/05/17/day.csv
level_data/2021/05/18 exists
made level_data/2021/05/18/day.csv
level_data/2021/05/19 exists
made level_data/2021/05/19/day.csv
level_data/2021/05/20 exists
made level_data/2021/05/20/day.csv
level_data/2021/05/21 exists
made level_data/2021/05/21/day.csv
level_data/2021/05/22 exists
made level_data/2021/05/22/day.csv
level_data/2021/05/23 exists
made level_data/2021/05/23/day.csv
level_data/2021/05/24 exists
made level_data/2021/05/24/day.csv
level_data/2021/05/25 exists
made level_data/2021/05/25/day.csv
level_data/2021/05/26 exists
made level_data/2021/05/26/day.csv
level_data/2021/05/27 exists
made level_data/2021/05/27/day.csv
level_data/2021/05/28 exists
made level_data/2021/05/28/day.csv
level_data/2021/05/29 exists
made level_data/2021/05/29/day.csv
level_data/2021/05/30 exists
made level_data/2021/05/30/day.csv
level_data/2021/06 exists
made level_data/2021/06/month.csv
level_data/2021/06/01 exists
made level_data/2021/06/01/day.csv
level_data/2021/06/02 exists
made level_data/2021/06/02/day.csv
level_data/2021/06/03 exists
made level_data/2021/06/03/day.csv
level_data/2021/06/04 exists
made level_data/2021/06/04/day.csv
level_data/2021/06/05 exists
made level_data/2021/06/05/day.csv
level_data/2021/06/06 exists
made level_data/2021/06/06/day.csv
level_data/2021/06/07 exists
made level_data/2021/06/07/day.csv
level_data/2021/06/08 exists
made level_data/2021/06/08/day.csv
level_data/2021/06/09 exists
made level_data/2021/06/09/day.csv
level_data/2021/06/10 exists
made level_data/2021/06/10/day.csv
level_data/2021/06/11 exists
made level_data/2021/06/11/day.csv
level_data/2021/06/12 exists
made level_data/2021/06/12/day.csv
level_data/2021/06/13 exists
made level_data/2021/06/13/day.csv
level_data/2021/06/14 exists
made level_data/2021/06/14/day.csv
level_data/2021/06/15 exists
made level_data/2021/06/15/day.csv
level_data/2021/06/16 exists
made level_data/2021/06/16/day.csv
level_data/2021/06/17 exists
made level_data/2021/06/17/day.csv
level_data/2021/06/18 exists
made level_data/2021/06/18/day.csv
level_data/2021/06/19 exists
made level_data/2021/06/19/day.csv
level_data/2021/06/20 exists
made level_data/2021/06/20/day.csv
level_data/2021/06/21 exists
made level_data/2021/06/21/day.csv
level_data/2021/06/22 exists
made level_data/2021/06/22/day.csv
level_data/2021/06/23 exists
made level_data/2021/06/23/day.csv
level_data/2021/06/24 exists
made level_data/2021/06/24/day.csv
level_data/2021/06/25 exists
made level_data/2021/06/25/day.csv
level_data/2021/06/26 exists
made level_data/2021/06/26/day.csv
level_data/2021/06/27 exists
made level_data/2021/06/27/day.csv
level_data/2021/06/28 exists
made level_data/2021/06/28/day.csv
level_data/2021/06/29 exists
made level_data/2021/06/29/day.csv
level_data/2021/06/30 exists
made level_data/2021/06/30/day.csv
level_data/2021/07 exists
made level_data/2021/07/month.csv
level_data/2021/07/01 exists
made level_data/2021/07/01/day.csv
level_data/2021/07/02 exists
made level_data/2021/07/02/day.csv
level_data/2021/07/03 exists
made level_data/2021/07/03/day.csv
level_data/2021/07/04 exists
made level_data/2021/07/04/day.csv
level_data/2021/07/05 exists
made level_data/2021/07/05/day.csv
level_data/2021/07/06 exists
made level_data/2021/07/06/day.csv
level_data/2021/07/07 exists
made level_data/2021/07/07/day.csv
level_data/2021/07/08 exists
made level_data/2021/07/08/day.csv
level_data/2021/07/09 exists
made level_data/2021/07/09/day.csv
level_data/2021/07/10 exists
made level_data/2021/07/10/day.csv
level_data/2021/07/11 exists
made level_data/2021/07/11/day.csv
level_data/2021/07/12 exists
made level_data/2021/07/12/day.csv
level_data/2021/07/13 exists
made level_data/2021/07/13/day.csv
level_data/2021/07/14 exists
made level_data/2021/07/14/day.csv
level_data/2021/07/15 exists
made level_data/2021/07/15/day.csv
level_data/2021/07/16 exists
made level_data/2021/07/16/day.csv
level_data/2021/07/17 exists
made level_data/2021/07/17/day.csv
level_data/2021/07/18 exists
made level_data/2021/07/18/day.csv
level_data/2021/07/19 exists
made level_data/2021/07/19/day.csv
level_data/2021/07/20 exists
made level_data/2021/07/20/day.csv
level_data/2021/07/21 exists
made level_data/2021/07/21/day.csv
level_data/2021/07/22 exists
made level_data/2021/07/22/day.csv
level_data/2021/07/23 exists
made level_data/2021/07/23/day.csv
level_data/2021/07/24 exists
made level_data/2021/07/24/day.csv
level_data/2021/07/25 exists
made level_data/2021/07/25/day.csv
level_data/2021/07/26 exists
made level_data/2021/07/26/day.csv
level_data/2021/07/27 exists
made level_data/2021/07/27/day.csv
level_data/2021/07/28 exists
made level_data/2021/07/28/day.csv
level_data/2021/07/29 exists
made level_data/2021/07/29/day.csv
level_data/2021/07/30 exists
made level_data/2021/07/30/day.csv
level_data/2021/08 exists
made level_data/2021/08/month.csv
level_data/2021/08/01 exists
made level_data/2021/08/01/day.csv
level_data/2021/08/02 exists
made level_data/2021/08/02/day.csv
level_data/2021/08/03 exists
made level_data/2021/08/03/day.csv
level_data/2021/08/04 exists
made level_data/2021/08/04/day.csv
level_data/2021/08/05 exists
made level_data/2021/08/05/day.csv
level_data/2021/08/06 exists
made level_data/2021/08/06/day.csv
level_data/2021/08/07 exists
made level_data/2021/08/07/day.csv
level_data/2021/08/08 exists
made level_data/2021/08/08/day.csv
level_data/2021/08/09 exists
made level_data/2021/08/09/day.csv
level_data/2021/08/10 exists
made level_data/2021/08/10/day.csv
level_data/2021/08/11 exists
made level_data/2021/08/11/day.csv
level_data/2021/08/12 exists
made level_data/2021/08/12/day.csv
level_data/2021/08/13 exists
made level_data/2021/08/13/day.csv
level_data/2021/08/14 exists
made level_data/2021/08/14/day.csv
level_data/2021/08/15 exists
made level_data/2021/08/15/day.csv
level_data/2021/08/16 exists
made level_data/2021/08/16/day.csv
level_data/2021/08/17 exists
made level_data/2021/08/17/day.csv
level_data/2021/08/18 exists
made level_data/2021/08/18/day.csv
level_data/2021/08/19 exists
made level_data/2021/08/19/day.csv
level_data/2021/08/20 exists
made level_data/2021/08/20/day.csv
level_data/2021/08/21 exists
made level_data/2021/08/21/day.csv
level_data/2021/08/22 exists
made level_data/2021/08/22/day.csv
level_data/2021/08/23 exists
made level_data/2021/08/23/day.csv
level_data/2021/08/24 exists
made level_data/2021/08/24/day.csv
level_data/2021/08/25 exists
made level_data/2021/08/25/day.csv
level_data/2021/08/26 exists
made level_data/2021/08/26/day.csv
level_data/2021/08/27 exists
made level_data/2021/08/27/day.csv
level_data/2021/08/28 exists
made level_data/2021/08/28/day.csv
level_data/2021/08/29 exists
made level_data/2021/08/29/day.csv
level_data/2021/08/30 exists
made level_data/2021/08/30/day.csv
level_data/2021/09 exists
made level_data/2021/09/month.csv
level_data/2021/09/01 exists
made level_data/2021/09/01/day.csv
level_data/2021/09/02 exists
made level_data/2021/09/02/day.csv
level_data/2021/09/03 exists
made level_data/2021/09/03/day.csv
level_data/2021/09/04 exists
made level_data/2021/09/04/day.csv
level_data/2021/09/05 exists
made level_data/2021/09/05/day.csv
level_data/2021/09/06 exists
made level_data/2021/09/06/day.csv
level_data/2021/09/07 exists
made level_data/2021/09/07/day.csv
level_data/2021/09/08 exists
made level_data/2021/09/08/day.csv
level_data/2021/09/09 exists
made level_data/2021/09/09/day.csv
level_data/2021/09/10 exists
made level_data/2021/09/10/day.csv
level_data/2021/09/11 exists
made level_data/2021/09/11/day.csv
level_data/2021/09/12 exists
made level_data/2021/09/12/day.csv
level_data/2021/09/13 exists
made level_data/2021/09/13/day.csv
level_data/2021/09/14 exists
made level_data/2021/09/14/day.csv
level_data/2021/09/15 exists
made level_data/2021/09/15/day.csv
level_data/2021/09/16 exists
made level_data/2021/09/16/day.csv
level_data/2021/09/17 exists
made level_data/2021/09/17/day.csv
level_data/2021/09/18 exists
made level_data/2021/09/18/day.csv
level_data/2021/09/19 exists
made level_data/2021/09/19/day.csv
level_data/2021/09/20 exists
made level_data/2021/09/20/day.csv
level_data/2021/09/21 exists
made level_data/2021/09/21/day.csv
level_data/2021/09/22 exists
made level_data/2021/09/22/day.csv
level_data/2021/09/23 exists
made level_data/2021/09/23/day.csv
level_data/2021/09/24 exists
made level_data/2021/09/24/day.csv
level_data/2021/09/25 exists
made level_data/2021/09/25/day.csv
level_data/2021/09/26 exists
made level_data/2021/09/26/day.csv
level_data/2021/09/27 exists
made level_data/2021/09/27/day.csv
level_data/2021/09/28 exists
made level_data/2021/09/28/day.csv
level_data/2021/09/29 exists
made level_data/2021/09/29/day.csv
level_data/2021/09/30 exists
made level_data/2021/09/30/day.csv
level_data/2021/10 exists
made level_data/2021/10/month.csv
level_data/2021/10/01 exists
made level_data/2021/10/01/day.csv
level_data/2021/10/02 exists
made level_data/2021/10/02/day.csv
level_data/2021/10/03 exists
made level_data/2021/10/03/day.csv
level_data/2021/10/04 exists
made level_data/2021/10/04/day.csv
level_data/2021/10/05 exists
made level_data/2021/10/05/day.csv
level_data/2021/10/06 exists
made level_data/2021/10/06/day.csv
level_data/2021/10/07 exists
made level_data/2021/10/07/day.csv
level_data/2021/10/08 exists
made level_data/2021/10/08/day.csv
level_data/2021/10/09 exists
made level_data/2021/10/09/day.csv
level_data/2021/10/10 exists
made level_data/2021/10/10/day.csv
level_data/2021/10/11 exists
made level_data/2021/10/11/day.csv
level_data/2021/10/12 exists
made level_data/2021/10/12/day.csv
level_data/2021/10/13 exists
made level_data/2021/10/13/day.csv
level_data/2021/10/14 exists
made level_data/2021/10/14/day.csv
level_data/2021/10/15 exists
made level_data/2021/10/15/day.csv
level_data/2021/10/16 exists
made level_data/2021/10/16/day.csv
level_data/2021/10/17 exists
made level_data/2021/10/17/day.csv
level_data/2021/10/18 exists
made level_data/2021/10/18/day.csv
level_data/2021/10/19 exists
made level_data/2021/10/19/day.csv
level_data/2021/10/20 exists
made level_data/2021/10/20/day.csv
level_data/2021/10/21 exists
made level_data/2021/10/21/day.csv
level_data/2021/10/22 exists
made level_data/2021/10/22/day.csv
level_data/2021/10/23 exists
made level_data/2021/10/23/day.csv
level_data/2021/10/24 exists
made level_data/2021/10/24/day.csv
level_data/2021/10/25 exists
made level_data/2021/10/25/day.csv
level_data/2021/10/26 exists
made level_data/2021/10/26/day.csv
level_data/2021/10/27 exists
made level_data/2021/10/27/day.csv
level_data/2021/10/28 exists
made level_data/2021/10/28/day.csv
level_data/2021/10/29 exists
made level_data/2021/10/29/day.csv
level_data/2021/10/30 exists
made level_data/2021/10/30/day.csv
level_data/2021/11 exists
made level_data/2021/11/month.csv
level_data/2021/11/01 exists
made level_data/2021/11/01/day.csv
level_data/2021/11/02 exists
made level_data/2021/11/02/day.csv
level_data/2021/11/03 exists
made level_data/2021/11/03/day.csv
level_data/2021/11/04 exists
made level_data/2021/11/04/day.csv
level_data/2021/11/05 exists
made level_data/2021/11/05/day.csv
level_data/2021/11/06 exists
made level_data/2021/11/06/day.csv
level_data/2021/11/07 exists
made level_data/2021/11/07/day.csv
level_data/2021/11/08 exists
made level_data/2021/11/08/day.csv
level_data/2021/11/09 exists
made level_data/2021/11/09/day.csv
level_data/2021/11/10 exists
made level_data/2021/11/10/day.csv
level_data/2021/11/11 exists
made level_data/2021/11/11/day.csv
level_data/2021/11/12 exists
made level_data/2021/11/12/day.csv
level_data/2021/11/13 exists
made level_data/2021/11/13/day.csv
level_data/2021/11/14 exists
made level_data/2021/11/14/day.csv
level_data/2021/11/15 exists
made level_data/2021/11/15/day.csv
level_data/2021/11/16 exists
made level_data/2021/11/16/day.csv
level_data/2021/11/17 exists
made level_data/2021/11/17/day.csv
level_data/2021/11/18 exists
made level_data/2021/11/18/day.csv
level_data/2021/11/19 exists
made level_data/2021/11/19/day.csv
level_data/2021/11/20 exists
made level_data/2021/11/20/day.csv
level_data/2021/11/21 exists
made level_data/2021/11/21/day.csv
level_data/2021/11/22 exists
made level_data/2021/11/22/day.csv
level_data/2021/11/23 exists
made level_data/2021/11/23/day.csv
level_data/2021/11/24 exists
made level_data/2021/11/24/day.csv
level_data/2021/11/25 exists
made level_data/2021/11/25/day.csv
level_data/2021/11/26 exists
made level_data/2021/11/26/day.csv
level_data/2021/11/27 exists
made level_data/2021/11/27/day.csv
level_data/2021/11/28 exists
made level_data/2021/11/28/day.csv
level_data/2021/11/29 exists
made level_data/2021/11/29/day.csv
level_data/2021/11/30 exists
made level_data/2021/11/30/day.csv
level_data/2021/12 exists
made level_data/2021/12/month.csv
level_data/2021/12/01 exists
made level_data/2021/12/01/day.csv
level_data/2021/12/02 exists
made level_data/2021/12/02/day.csv
level_data/2021/12/03 exists
made level_data/2021/12/03/day.csv
level_data/2021/12/04 exists
made level_data/2021/12/04/day.csv
level_data/2021/12/05 exists
made level_data/2021/12/05/day.csv
level_data/2021/12/06 exists
made level_data/2021/12/06/day.csv
level_data/2021/12/07 exists
made level_data/2021/12/07/day.csv
level_data/2021/12/08 exists
made level_data/2021/12/08/day.csv
level_data/2021/12/09 exists
made level_data/2021/12/09/day.csv
level_data/2021/12/10 exists
made level_data/2021/12/10/day.csv
level_data/2021/12/11 exists
made level_data/2021/12/11/day.csv
level_data/2021/12/12 exists
made level_data/2021/12/12/day.csv
level_data/2021/12/13 exists
made level_data/2021/12/13/day.csv
level_data/2021/12/14 exists
made level_data/2021/12/14/day.csv
level_data/2021/12/15 exists
made level_data/2021/12/15/day.csv
level_data/2021/12/16 exists
made level_data/2021/12/16/day.csv
level_data/2021/12/17 exists
made level_data/2021/12/17/day.csv
level_data/2021/12/18 exists
made level_data/2021/12/18/day.csv
level_data/2021/12/19 exists
made level_data/2021/12/19/day.csv
level_data/2021/12/20 exists
made level_data/2021/12/20/day.csv
level_data/2021/12/21 exists
made level_data/2021/12/21/day.csv
level_data/2021/12/22 exists
made level_data/2021/12/22/day.csv
level_data/2021/12/23 exists
made level_data/2021/12/23/day.csv
level_data/2021/12/24 exists
made level_data/2021/12/24/day.csv
level_data/2021/12/25 exists
made level_data/2021/12/25/day.csv
level_data/2021/12/26 exists
made level_data/2021/12/26/day.csv
level_data/2021/12/27 exists
made level_data/2021/12/27/day.csv
level_data/2021/12/28 exists
made level_data/2021/12/28/day.csv
level_data/2021/12/29 exists
made level_data/2021/12/29/day.csv
level_data/2021/12/30 exists
made level_data/2021/12/30/day.csv

Walking a Directory

The os module provides walk, which is a generator function that traverses a directory and all its subdirectories, and all their subdirectories, and so on.

For each directory, it yields:

  • dirpath, which is the name of the directory.

  • dirnames, which is a list of subdirectories it contains, and

  • filenames, which is a list of files it contains.

Here’s how we can use it to print the paths of all files in the directory we created.

for dirpath, dirnames, filenames in os.walk('level_data'):
    for filename in filenames:
        path = os.path.join(dirpath, filename)
        print(path)
level_data/2021/year.csv
level_data/2021/04/month.csv
level_data/2021/04/04/day.csv
level_data/2021/04/24/day.csv
level_data/2021/04/09/day.csv
level_data/2021/04/02/day.csv
level_data/2021/04/27/day.csv
level_data/2021/04/17/day.csv
level_data/2021/04/21/day.csv
level_data/2021/04/18/day.csv
level_data/2021/04/14/day.csv
level_data/2021/04/23/day.csv
level_data/2021/04/01/day.csv
level_data/2021/04/10/day.csv
level_data/2021/04/30/day.csv
level_data/2021/04/15/day.csv
level_data/2021/04/12/day.csv
level_data/2021/04/06/day.csv
level_data/2021/04/05/day.csv
level_data/2021/04/29/day.csv
level_data/2021/04/07/day.csv
level_data/2021/04/28/day.csv
level_data/2021/04/08/day.csv
level_data/2021/04/03/day.csv
level_data/2021/04/20/day.csv
level_data/2021/04/22/day.csv
level_data/2021/04/11/day.csv
level_data/2021/04/25/day.csv
level_data/2021/04/13/day.csv
level_data/2021/04/16/day.csv
level_data/2021/04/26/day.csv
level_data/2021/04/19/day.csv
level_data/2021/09/month.csv
level_data/2021/09/04/day.csv
level_data/2021/09/24/day.csv
level_data/2021/09/09/day.csv
level_data/2021/09/02/day.csv
level_data/2021/09/27/day.csv
level_data/2021/09/17/day.csv
level_data/2021/09/21/day.csv
level_data/2021/09/18/day.csv
level_data/2021/09/14/day.csv
level_data/2021/09/23/day.csv
level_data/2021/09/01/day.csv
level_data/2021/09/10/day.csv
level_data/2021/09/30/day.csv
level_data/2021/09/15/day.csv
level_data/2021/09/12/day.csv
level_data/2021/09/06/day.csv
level_data/2021/09/05/day.csv
level_data/2021/09/29/day.csv
level_data/2021/09/07/day.csv
level_data/2021/09/28/day.csv
level_data/2021/09/08/day.csv
level_data/2021/09/03/day.csv
level_data/2021/09/20/day.csv
level_data/2021/09/22/day.csv
level_data/2021/09/11/day.csv
level_data/2021/09/25/day.csv
level_data/2021/09/13/day.csv
level_data/2021/09/16/day.csv
level_data/2021/09/26/day.csv
level_data/2021/09/19/day.csv
level_data/2021/02/month.csv
level_data/2021/02/04/day.csv
level_data/2021/02/24/day.csv
level_data/2021/02/09/day.csv
level_data/2021/02/02/day.csv
level_data/2021/02/27/day.csv
level_data/2021/02/17/day.csv
level_data/2021/02/21/day.csv
level_data/2021/02/18/day.csv
level_data/2021/02/14/day.csv
level_data/2021/02/23/day.csv
level_data/2021/02/01/day.csv
level_data/2021/02/10/day.csv
level_data/2021/02/30/day.csv
level_data/2021/02/15/day.csv
level_data/2021/02/12/day.csv
level_data/2021/02/06/day.csv
level_data/2021/02/05/day.csv
level_data/2021/02/29/day.csv
level_data/2021/02/07/day.csv
level_data/2021/02/28/day.csv
level_data/2021/02/08/day.csv
level_data/2021/02/03/day.csv
level_data/2021/02/20/day.csv
level_data/2021/02/22/day.csv
level_data/2021/02/11/day.csv
level_data/2021/02/25/day.csv
level_data/2021/02/13/day.csv
level_data/2021/02/16/day.csv
level_data/2021/02/26/day.csv
level_data/2021/02/19/day.csv
level_data/2021/01/month.csv
level_data/2021/01/04/day.csv
level_data/2021/01/24/day.csv
level_data/2021/01/09/day.csv
level_data/2021/01/02/day.csv
level_data/2021/01/27/day.csv
level_data/2021/01/17/day.csv
level_data/2021/01/21/day.csv
level_data/2021/01/18/day.csv
level_data/2021/01/14/day.csv
level_data/2021/01/23/day.csv
level_data/2021/01/01/day.csv
level_data/2021/01/10/day.csv
level_data/2021/01/30/day.csv
level_data/2021/01/15/day.csv
level_data/2021/01/12/day.csv
level_data/2021/01/06/day.csv
level_data/2021/01/05/day.csv
level_data/2021/01/29/day.csv
level_data/2021/01/07/day.csv
level_data/2021/01/28/day.csv
level_data/2021/01/08/day.csv
level_data/2021/01/03/day.csv
level_data/2021/01/20/day.csv
level_data/2021/01/22/day.csv
level_data/2021/01/11/day.csv
level_data/2021/01/25/day.csv
level_data/2021/01/13/day.csv
level_data/2021/01/16/day.csv
level_data/2021/01/26/day.csv
level_data/2021/01/19/day.csv
level_data/2021/10/month.csv
level_data/2021/10/04/day.csv
level_data/2021/10/24/day.csv
level_data/2021/10/09/day.csv
level_data/2021/10/02/day.csv
level_data/2021/10/27/day.csv
level_data/2021/10/17/day.csv
level_data/2021/10/21/day.csv
level_data/2021/10/18/day.csv
level_data/2021/10/14/day.csv
level_data/2021/10/23/day.csv
level_data/2021/10/01/day.csv
level_data/2021/10/10/day.csv
level_data/2021/10/30/day.csv
level_data/2021/10/15/day.csv
level_data/2021/10/12/day.csv
level_data/2021/10/06/day.csv
level_data/2021/10/05/day.csv
level_data/2021/10/29/day.csv
level_data/2021/10/07/day.csv
level_data/2021/10/28/day.csv
level_data/2021/10/08/day.csv
level_data/2021/10/03/day.csv
level_data/2021/10/20/day.csv
level_data/2021/10/22/day.csv
level_data/2021/10/11/day.csv
level_data/2021/10/25/day.csv
level_data/2021/10/13/day.csv
level_data/2021/10/16/day.csv
level_data/2021/10/26/day.csv
level_data/2021/10/19/day.csv
level_data/2021/12/month.csv
level_data/2021/12/04/day.csv
level_data/2021/12/24/day.csv
level_data/2021/12/09/day.csv
level_data/2021/12/02/day.csv
level_data/2021/12/27/day.csv
level_data/2021/12/17/day.csv
level_data/2021/12/21/day.csv
level_data/2021/12/18/day.csv
level_data/2021/12/14/day.csv
level_data/2021/12/23/day.csv
level_data/2021/12/01/day.csv
level_data/2021/12/10/day.csv
level_data/2021/12/30/day.csv
level_data/2021/12/15/day.csv
level_data/2021/12/12/day.csv
level_data/2021/12/06/day.csv
level_data/2021/12/05/day.csv
level_data/2021/12/29/day.csv
level_data/2021/12/07/day.csv
level_data/2021/12/28/day.csv
level_data/2021/12/08/day.csv
level_data/2021/12/03/day.csv
level_data/2021/12/20/day.csv
level_data/2021/12/22/day.csv
level_data/2021/12/11/day.csv
level_data/2021/12/25/day.csv
level_data/2021/12/13/day.csv
level_data/2021/12/16/day.csv
level_data/2021/12/26/day.csv
level_data/2021/12/19/day.csv
level_data/2021/06/month.csv
level_data/2021/06/04/day.csv
level_data/2021/06/24/day.csv
level_data/2021/06/09/day.csv
level_data/2021/06/02/day.csv
level_data/2021/06/27/day.csv
level_data/2021/06/17/day.csv
level_data/2021/06/21/day.csv
level_data/2021/06/18/day.csv
level_data/2021/06/14/day.csv
level_data/2021/06/23/day.csv
level_data/2021/06/01/day.csv
level_data/2021/06/10/day.csv
level_data/2021/06/30/day.csv
level_data/2021/06/15/day.csv
level_data/2021/06/12/day.csv
level_data/2021/06/06/day.csv
level_data/2021/06/05/day.csv
level_data/2021/06/29/day.csv
level_data/2021/06/07/day.csv
level_data/2021/06/28/day.csv
level_data/2021/06/08/day.csv
level_data/2021/06/03/day.csv
level_data/2021/06/20/day.csv
level_data/2021/06/22/day.csv
level_data/2021/06/11/day.csv
level_data/2021/06/25/day.csv
level_data/2021/06/13/day.csv
level_data/2021/06/16/day.csv
level_data/2021/06/26/day.csv
level_data/2021/06/19/day.csv
level_data/2021/05/month.csv
level_data/2021/05/04/day.csv
level_data/2021/05/24/day.csv
level_data/2021/05/09/day.csv
level_data/2021/05/02/day.csv
level_data/2021/05/27/day.csv
level_data/2021/05/17/day.csv
level_data/2021/05/21/day.csv
level_data/2021/05/18/day.csv
level_data/2021/05/14/day.csv
level_data/2021/05/23/day.csv
level_data/2021/05/01/day.csv
level_data/2021/05/10/day.csv
level_data/2021/05/30/day.csv
level_data/2021/05/15/day.csv
level_data/2021/05/12/day.csv
level_data/2021/05/06/day.csv
level_data/2021/05/05/day.csv
level_data/2021/05/29/day.csv
level_data/2021/05/07/day.csv
level_data/2021/05/28/day.csv
level_data/2021/05/08/day.csv
level_data/2021/05/03/day.csv
level_data/2021/05/20/day.csv
level_data/2021/05/22/day.csv
level_data/2021/05/11/day.csv
level_data/2021/05/25/day.csv
level_data/2021/05/13/day.csv
level_data/2021/05/16/day.csv
level_data/2021/05/26/day.csv
level_data/2021/05/19/day.csv
level_data/2021/07/month.csv
level_data/2021/07/04/day.csv
level_data/2021/07/24/day.csv
level_data/2021/07/09/day.csv
level_data/2021/07/02/day.csv
level_data/2021/07/27/day.csv
level_data/2021/07/17/day.csv
level_data/2021/07/21/day.csv
level_data/2021/07/18/day.csv
level_data/2021/07/14/day.csv
level_data/2021/07/23/day.csv
level_data/2021/07/01/day.csv
level_data/2021/07/10/day.csv
level_data/2021/07/30/day.csv
level_data/2021/07/15/day.csv
level_data/2021/07/12/day.csv
level_data/2021/07/06/day.csv
level_data/2021/07/05/day.csv
level_data/2021/07/29/day.csv
level_data/2021/07/07/day.csv
level_data/2021/07/28/day.csv
level_data/2021/07/08/day.csv
level_data/2021/07/03/day.csv
level_data/2021/07/20/day.csv
level_data/2021/07/22/day.csv
level_data/2021/07/11/day.csv
level_data/2021/07/25/day.csv
level_data/2021/07/13/day.csv
level_data/2021/07/16/day.csv
level_data/2021/07/26/day.csv
level_data/2021/07/19/day.csv
level_data/2021/08/month.csv
level_data/2021/08/04/day.csv
level_data/2021/08/24/day.csv
level_data/2021/08/09/day.csv
level_data/2021/08/02/day.csv
level_data/2021/08/27/day.csv
level_data/2021/08/17/day.csv
level_data/2021/08/21/day.csv
level_data/2021/08/18/day.csv
level_data/2021/08/14/day.csv
level_data/2021/08/23/day.csv
level_data/2021/08/01/day.csv
level_data/2021/08/10/day.csv
level_data/2021/08/30/day.csv
level_data/2021/08/15/day.csv
level_data/2021/08/12/day.csv
level_data/2021/08/06/day.csv
level_data/2021/08/05/day.csv
level_data/2021/08/29/day.csv
level_data/2021/08/07/day.csv
level_data/2021/08/28/day.csv
level_data/2021/08/08/day.csv
level_data/2021/08/03/day.csv
level_data/2021/08/20/day.csv
level_data/2021/08/22/day.csv
level_data/2021/08/11/day.csv
level_data/2021/08/25/day.csv
level_data/2021/08/13/day.csv
level_data/2021/08/16/day.csv
level_data/2021/08/26/day.csv
level_data/2021/08/19/day.csv
level_data/2021/03/month.csv
level_data/2021/03/04/day.csv
level_data/2021/03/24/day.csv
level_data/2021/03/09/day.csv
level_data/2021/03/02/day.csv
level_data/2021/03/27/day.csv
level_data/2021/03/17/day.csv
level_data/2021/03/21/day.csv
level_data/2021/03/18/day.csv
level_data/2021/03/14/day.csv
level_data/2021/03/23/day.csv
level_data/2021/03/01/day.csv
level_data/2021/03/10/day.csv
level_data/2021/03/30/day.csv
level_data/2021/03/15/day.csv
level_data/2021/03/12/day.csv
level_data/2021/03/06/day.csv
level_data/2021/03/05/day.csv
level_data/2021/03/29/day.csv
level_data/2021/03/07/day.csv
level_data/2021/03/28/day.csv
level_data/2021/03/08/day.csv
level_data/2021/03/03/day.csv
level_data/2021/03/20/day.csv
level_data/2021/03/22/day.csv
level_data/2021/03/11/day.csv
level_data/2021/03/25/day.csv
level_data/2021/03/13/day.csv
level_data/2021/03/16/day.csv
level_data/2021/03/26/day.csv
level_data/2021/03/19/day.csv
level_data/2021/11/month.csv
level_data/2021/11/04/day.csv
level_data/2021/11/24/day.csv
level_data/2021/11/09/day.csv
level_data/2021/11/02/day.csv
level_data/2021/11/27/day.csv
level_data/2021/11/17/day.csv
level_data/2021/11/21/day.csv
level_data/2021/11/18/day.csv
level_data/2021/11/14/day.csv
level_data/2021/11/23/day.csv
level_data/2021/11/01/day.csv
level_data/2021/11/10/day.csv
level_data/2021/11/30/day.csv
level_data/2021/11/15/day.csv
level_data/2021/11/12/day.csv
level_data/2021/11/06/day.csv
level_data/2021/11/05/day.csv
level_data/2021/11/29/day.csv
level_data/2021/11/07/day.csv
level_data/2021/11/28/day.csv
level_data/2021/11/08/day.csv
level_data/2021/11/03/day.csv
level_data/2021/11/20/day.csv
level_data/2021/11/22/day.csv
level_data/2021/11/11/day.csv
level_data/2021/11/25/day.csv
level_data/2021/11/13/day.csv
level_data/2021/11/16/day.csv
level_data/2021/11/26/day.csv
level_data/2021/11/19/day.csv
level_data/2021/00/month.csv
level_data/2021/00/04/day.csv
level_data/2021/00/24/day.csv
level_data/2021/00/09/day.csv
level_data/2021/00/02/day.csv
level_data/2021/00/27/day.csv
level_data/2021/00/17/day.csv
level_data/2021/00/21/day.csv
level_data/2021/00/18/day.csv
level_data/2021/00/14/day.csv
level_data/2021/00/23/day.csv
level_data/2021/00/01/day.csv
level_data/2021/00/10/day.csv
level_data/2021/00/30/day.csv
level_data/2021/00/15/day.csv
level_data/2021/00/12/day.csv
level_data/2021/00/06/day.csv
level_data/2021/00/05/day.csv
level_data/2021/00/29/day.csv
level_data/2021/00/07/day.csv
level_data/2021/00/28/day.csv
level_data/2021/00/08/day.csv
level_data/2021/00/03/day.csv
level_data/2021/00/20/day.csv
level_data/2021/00/22/day.csv
level_data/2021/00/11/day.csv
level_data/2021/00/25/day.csv
level_data/2021/00/13/day.csv
level_data/2021/00/16/day.csv
level_data/2021/00/26/day.csv
level_data/2021/00/19/day.csv

One quirk of os.walk is that the directories and files don’t appear in any particular order. Of course, we can store the results and sort them in whatever order we want.

But as an exercise, we can write our own version of walk. We’ll need two functions:

  • os.listdir, which takes a directory and list the directories and files it contains, and

  • os.path.isfile, which takes a path and returns True if it is a file, and False if it is a directory or something else.

You might notice that some file-related functions are in the submodule os.path. There is some logic to this organization, but it is not always obvious why a particular function is in this submodule or not.

Anyway, here is a recursive version of walk:

def walk(dirname):
    for name in sorted(os.listdir(dirname)):
        path = os.path.join(dirname, name)
        if os.path.isfile(path):
            print(path)
        else:
            walk(path)
walk(year_dir)
level_data/2021/00/01/day.csv
level_data/2021/00/02/day.csv
level_data/2021/00/03/day.csv
level_data/2021/00/04/day.csv
level_data/2021/00/05/day.csv
level_data/2021/00/06/day.csv
level_data/2021/00/07/day.csv
level_data/2021/00/08/day.csv
level_data/2021/00/09/day.csv
level_data/2021/00/10/day.csv
level_data/2021/00/11/day.csv
level_data/2021/00/12/day.csv
level_data/2021/00/13/day.csv
level_data/2021/00/14/day.csv
level_data/2021/00/15/day.csv
level_data/2021/00/16/day.csv
level_data/2021/00/17/day.csv
level_data/2021/00/18/day.csv
level_data/2021/00/19/day.csv
level_data/2021/00/20/day.csv
level_data/2021/00/21/day.csv
level_data/2021/00/22/day.csv
level_data/2021/00/23/day.csv
level_data/2021/00/24/day.csv
level_data/2021/00/25/day.csv
level_data/2021/00/26/day.csv
level_data/2021/00/27/day.csv
level_data/2021/00/28/day.csv
level_data/2021/00/29/day.csv
level_data/2021/00/30/day.csv
level_data/2021/00/month.csv
level_data/2021/01/01/day.csv
level_data/2021/01/02/day.csv
level_data/2021/01/03/day.csv
level_data/2021/01/04/day.csv
level_data/2021/01/05/day.csv
level_data/2021/01/06/day.csv
level_data/2021/01/07/day.csv
level_data/2021/01/08/day.csv
level_data/2021/01/09/day.csv
level_data/2021/01/10/day.csv
level_data/2021/01/11/day.csv
level_data/2021/01/12/day.csv
level_data/2021/01/13/day.csv
level_data/2021/01/14/day.csv
level_data/2021/01/15/day.csv
level_data/2021/01/16/day.csv
level_data/2021/01/17/day.csv
level_data/2021/01/18/day.csv
level_data/2021/01/19/day.csv
level_data/2021/01/20/day.csv
level_data/2021/01/21/day.csv
level_data/2021/01/22/day.csv
level_data/2021/01/23/day.csv
level_data/2021/01/24/day.csv
level_data/2021/01/25/day.csv
level_data/2021/01/26/day.csv
level_data/2021/01/27/day.csv
level_data/2021/01/28/day.csv
level_data/2021/01/29/day.csv
level_data/2021/01/30/day.csv
level_data/2021/01/month.csv
level_data/2021/02/01/day.csv
level_data/2021/02/02/day.csv
level_data/2021/02/03/day.csv
level_data/2021/02/04/day.csv
level_data/2021/02/05/day.csv
level_data/2021/02/06/day.csv
level_data/2021/02/07/day.csv
level_data/2021/02/08/day.csv
level_data/2021/02/09/day.csv
level_data/2021/02/10/day.csv
level_data/2021/02/11/day.csv
level_data/2021/02/12/day.csv
level_data/2021/02/13/day.csv
level_data/2021/02/14/day.csv
level_data/2021/02/15/day.csv
level_data/2021/02/16/day.csv
level_data/2021/02/17/day.csv
level_data/2021/02/18/day.csv
level_data/2021/02/19/day.csv
level_data/2021/02/20/day.csv
level_data/2021/02/21/day.csv
level_data/2021/02/22/day.csv
level_data/2021/02/23/day.csv
level_data/2021/02/24/day.csv
level_data/2021/02/25/day.csv
level_data/2021/02/26/day.csv
level_data/2021/02/27/day.csv
level_data/2021/02/28/day.csv
level_data/2021/02/29/day.csv
level_data/2021/02/30/day.csv
level_data/2021/02/month.csv
level_data/2021/03/01/day.csv
level_data/2021/03/02/day.csv
level_data/2021/03/03/day.csv
level_data/2021/03/04/day.csv
level_data/2021/03/05/day.csv
level_data/2021/03/06/day.csv
level_data/2021/03/07/day.csv
level_data/2021/03/08/day.csv
level_data/2021/03/09/day.csv
level_data/2021/03/10/day.csv
level_data/2021/03/11/day.csv
level_data/2021/03/12/day.csv
level_data/2021/03/13/day.csv
level_data/2021/03/14/day.csv
level_data/2021/03/15/day.csv
level_data/2021/03/16/day.csv
level_data/2021/03/17/day.csv
level_data/2021/03/18/day.csv
level_data/2021/03/19/day.csv
level_data/2021/03/20/day.csv
level_data/2021/03/21/day.csv
level_data/2021/03/22/day.csv
level_data/2021/03/23/day.csv
level_data/2021/03/24/day.csv
level_data/2021/03/25/day.csv
level_data/2021/03/26/day.csv
level_data/2021/03/27/day.csv
level_data/2021/03/28/day.csv
level_data/2021/03/29/day.csv
level_data/2021/03/30/day.csv
level_data/2021/03/month.csv
level_data/2021/04/01/day.csv
level_data/2021/04/02/day.csv
level_data/2021/04/03/day.csv
level_data/2021/04/04/day.csv
level_data/2021/04/05/day.csv
level_data/2021/04/06/day.csv
level_data/2021/04/07/day.csv
level_data/2021/04/08/day.csv
level_data/2021/04/09/day.csv
level_data/2021/04/10/day.csv
level_data/2021/04/11/day.csv
level_data/2021/04/12/day.csv
level_data/2021/04/13/day.csv
level_data/2021/04/14/day.csv
level_data/2021/04/15/day.csv
level_data/2021/04/16/day.csv
level_data/2021/04/17/day.csv
level_data/2021/04/18/day.csv
level_data/2021/04/19/day.csv
level_data/2021/04/20/day.csv
level_data/2021/04/21/day.csv
level_data/2021/04/22/day.csv
level_data/2021/04/23/day.csv
level_data/2021/04/24/day.csv
level_data/2021/04/25/day.csv
level_data/2021/04/26/day.csv
level_data/2021/04/27/day.csv
level_data/2021/04/28/day.csv
level_data/2021/04/29/day.csv
level_data/2021/04/30/day.csv
level_data/2021/04/month.csv
level_data/2021/05/01/day.csv
level_data/2021/05/02/day.csv
level_data/2021/05/03/day.csv
level_data/2021/05/04/day.csv
level_data/2021/05/05/day.csv
level_data/2021/05/06/day.csv
level_data/2021/05/07/day.csv
level_data/2021/05/08/day.csv
level_data/2021/05/09/day.csv
level_data/2021/05/10/day.csv
level_data/2021/05/11/day.csv
level_data/2021/05/12/day.csv
level_data/2021/05/13/day.csv
level_data/2021/05/14/day.csv
level_data/2021/05/15/day.csv
level_data/2021/05/16/day.csv
level_data/2021/05/17/day.csv
level_data/2021/05/18/day.csv
level_data/2021/05/19/day.csv
level_data/2021/05/20/day.csv
level_data/2021/05/21/day.csv
level_data/2021/05/22/day.csv
level_data/2021/05/23/day.csv
level_data/2021/05/24/day.csv
level_data/2021/05/25/day.csv
level_data/2021/05/26/day.csv
level_data/2021/05/27/day.csv
level_data/2021/05/28/day.csv
level_data/2021/05/29/day.csv
level_data/2021/05/30/day.csv
level_data/2021/05/month.csv
level_data/2021/06/01/day.csv
level_data/2021/06/02/day.csv
level_data/2021/06/03/day.csv
level_data/2021/06/04/day.csv
level_data/2021/06/05/day.csv
level_data/2021/06/06/day.csv
level_data/2021/06/07/day.csv
level_data/2021/06/08/day.csv
level_data/2021/06/09/day.csv
level_data/2021/06/10/day.csv
level_data/2021/06/11/day.csv
level_data/2021/06/12/day.csv
level_data/2021/06/13/day.csv
level_data/2021/06/14/day.csv
level_data/2021/06/15/day.csv
level_data/2021/06/16/day.csv
level_data/2021/06/17/day.csv
level_data/2021/06/18/day.csv
level_data/2021/06/19/day.csv
level_data/2021/06/20/day.csv
level_data/2021/06/21/day.csv
level_data/2021/06/22/day.csv
level_data/2021/06/23/day.csv
level_data/2021/06/24/day.csv
level_data/2021/06/25/day.csv
level_data/2021/06/26/day.csv
level_data/2021/06/27/day.csv
level_data/2021/06/28/day.csv
level_data/2021/06/29/day.csv
level_data/2021/06/30/day.csv
level_data/2021/06/month.csv
level_data/2021/07/01/day.csv
level_data/2021/07/02/day.csv
level_data/2021/07/03/day.csv
level_data/2021/07/04/day.csv
level_data/2021/07/05/day.csv
level_data/2021/07/06/day.csv
level_data/2021/07/07/day.csv
level_data/2021/07/08/day.csv
level_data/2021/07/09/day.csv
level_data/2021/07/10/day.csv
level_data/2021/07/11/day.csv
level_data/2021/07/12/day.csv
level_data/2021/07/13/day.csv
level_data/2021/07/14/day.csv
level_data/2021/07/15/day.csv
level_data/2021/07/16/day.csv
level_data/2021/07/17/day.csv
level_data/2021/07/18/day.csv
level_data/2021/07/19/day.csv
level_data/2021/07/20/day.csv
level_data/2021/07/21/day.csv
level_data/2021/07/22/day.csv
level_data/2021/07/23/day.csv
level_data/2021/07/24/day.csv
level_data/2021/07/25/day.csv
level_data/2021/07/26/day.csv
level_data/2021/07/27/day.csv
level_data/2021/07/28/day.csv
level_data/2021/07/29/day.csv
level_data/2021/07/30/day.csv
level_data/2021/07/month.csv
level_data/2021/08/01/day.csv
level_data/2021/08/02/day.csv
level_data/2021/08/03/day.csv
level_data/2021/08/04/day.csv
level_data/2021/08/05/day.csv
level_data/2021/08/06/day.csv
level_data/2021/08/07/day.csv
level_data/2021/08/08/day.csv
level_data/2021/08/09/day.csv
level_data/2021/08/10/day.csv
level_data/2021/08/11/day.csv
level_data/2021/08/12/day.csv
level_data/2021/08/13/day.csv
level_data/2021/08/14/day.csv
level_data/2021/08/15/day.csv
level_data/2021/08/16/day.csv
level_data/2021/08/17/day.csv
level_data/2021/08/18/day.csv
level_data/2021/08/19/day.csv
level_data/2021/08/20/day.csv
level_data/2021/08/21/day.csv
level_data/2021/08/22/day.csv
level_data/2021/08/23/day.csv
level_data/2021/08/24/day.csv
level_data/2021/08/25/day.csv
level_data/2021/08/26/day.csv
level_data/2021/08/27/day.csv
level_data/2021/08/28/day.csv
level_data/2021/08/29/day.csv
level_data/2021/08/30/day.csv
level_data/2021/08/month.csv
level_data/2021/09/01/day.csv
level_data/2021/09/02/day.csv
level_data/2021/09/03/day.csv
level_data/2021/09/04/day.csv
level_data/2021/09/05/day.csv
level_data/2021/09/06/day.csv
level_data/2021/09/07/day.csv
level_data/2021/09/08/day.csv
level_data/2021/09/09/day.csv
level_data/2021/09/10/day.csv
level_data/2021/09/11/day.csv
level_data/2021/09/12/day.csv
level_data/2021/09/13/day.csv
level_data/2021/09/14/day.csv
level_data/2021/09/15/day.csv
level_data/2021/09/16/day.csv
level_data/2021/09/17/day.csv
level_data/2021/09/18/day.csv
level_data/2021/09/19/day.csv
level_data/2021/09/20/day.csv
level_data/2021/09/21/day.csv
level_data/2021/09/22/day.csv
level_data/2021/09/23/day.csv
level_data/2021/09/24/day.csv
level_data/2021/09/25/day.csv
level_data/2021/09/26/day.csv
level_data/2021/09/27/day.csv
level_data/2021/09/28/day.csv
level_data/2021/09/29/day.csv
level_data/2021/09/30/day.csv
level_data/2021/09/month.csv
level_data/2021/10/01/day.csv
level_data/2021/10/02/day.csv
level_data/2021/10/03/day.csv
level_data/2021/10/04/day.csv
level_data/2021/10/05/day.csv
level_data/2021/10/06/day.csv
level_data/2021/10/07/day.csv
level_data/2021/10/08/day.csv
level_data/2021/10/09/day.csv
level_data/2021/10/10/day.csv
level_data/2021/10/11/day.csv
level_data/2021/10/12/day.csv
level_data/2021/10/13/day.csv
level_data/2021/10/14/day.csv
level_data/2021/10/15/day.csv
level_data/2021/10/16/day.csv
level_data/2021/10/17/day.csv
level_data/2021/10/18/day.csv
level_data/2021/10/19/day.csv
level_data/2021/10/20/day.csv
level_data/2021/10/21/day.csv
level_data/2021/10/22/day.csv
level_data/2021/10/23/day.csv
level_data/2021/10/24/day.csv
level_data/2021/10/25/day.csv
level_data/2021/10/26/day.csv
level_data/2021/10/27/day.csv
level_data/2021/10/28/day.csv
level_data/2021/10/29/day.csv
level_data/2021/10/30/day.csv
level_data/2021/10/month.csv
level_data/2021/11/01/day.csv
level_data/2021/11/02/day.csv
level_data/2021/11/03/day.csv
level_data/2021/11/04/day.csv
level_data/2021/11/05/day.csv
level_data/2021/11/06/day.csv
level_data/2021/11/07/day.csv
level_data/2021/11/08/day.csv
level_data/2021/11/09/day.csv
level_data/2021/11/10/day.csv
level_data/2021/11/11/day.csv
level_data/2021/11/12/day.csv
level_data/2021/11/13/day.csv
level_data/2021/11/14/day.csv
level_data/2021/11/15/day.csv
level_data/2021/11/16/day.csv
level_data/2021/11/17/day.csv
level_data/2021/11/18/day.csv
level_data/2021/11/19/day.csv
level_data/2021/11/20/day.csv
level_data/2021/11/21/day.csv
level_data/2021/11/22/day.csv
level_data/2021/11/23/day.csv
level_data/2021/11/24/day.csv
level_data/2021/11/25/day.csv
level_data/2021/11/26/day.csv
level_data/2021/11/27/day.csv
level_data/2021/11/28/day.csv
level_data/2021/11/29/day.csv
level_data/2021/11/30/day.csv
level_data/2021/11/month.csv
level_data/2021/12/01/day.csv
level_data/2021/12/02/day.csv
level_data/2021/12/03/day.csv
level_data/2021/12/04/day.csv
level_data/2021/12/05/day.csv
level_data/2021/12/06/day.csv
level_data/2021/12/07/day.csv
level_data/2021/12/08/day.csv
level_data/2021/12/09/day.csv
level_data/2021/12/10/day.csv
level_data/2021/12/11/day.csv
level_data/2021/12/12/day.csv
level_data/2021/12/13/day.csv
level_data/2021/12/14/day.csv
level_data/2021/12/15/day.csv
level_data/2021/12/16/day.csv
level_data/2021/12/17/day.csv
level_data/2021/12/18/day.csv
level_data/2021/12/19/day.csv
level_data/2021/12/20/day.csv
level_data/2021/12/21/day.csv
level_data/2021/12/22/day.csv
level_data/2021/12/23/day.csv
level_data/2021/12/24/day.csv
level_data/2021/12/25/day.csv
level_data/2021/12/26/day.csv
level_data/2021/12/27/day.csv
level_data/2021/12/28/day.csv
level_data/2021/12/29/day.csv
level_data/2021/12/30/day.csv
level_data/2021/12/month.csv
level_data/2021/year.csv

Exercise: Write a version of walk called walk_gen that is a generator function; that is, it should yield the paths it finds rather than printing them.

You can use the following loop to test your code.

for path in walk_gen(year_dir):
    print(path)
level_data/2021/00/01/day.csv
level_data/2021/00/02/day.csv
level_data/2021/00/03/day.csv
level_data/2021/00/04/day.csv
level_data/2021/00/05/day.csv
level_data/2021/00/06/day.csv
level_data/2021/00/07/day.csv
level_data/2021/00/08/day.csv
level_data/2021/00/09/day.csv
level_data/2021/00/10/day.csv
level_data/2021/00/11/day.csv
level_data/2021/00/12/day.csv
level_data/2021/00/13/day.csv
level_data/2021/00/14/day.csv
level_data/2021/00/15/day.csv
level_data/2021/00/16/day.csv
level_data/2021/00/17/day.csv
level_data/2021/00/18/day.csv
level_data/2021/00/19/day.csv
level_data/2021/00/20/day.csv
level_data/2021/00/21/day.csv
level_data/2021/00/22/day.csv
level_data/2021/00/23/day.csv
level_data/2021/00/24/day.csv
level_data/2021/00/25/day.csv
level_data/2021/00/26/day.csv
level_data/2021/00/27/day.csv
level_data/2021/00/28/day.csv
level_data/2021/00/29/day.csv
level_data/2021/00/30/day.csv
level_data/2021/00/month.csv
level_data/2021/01/01/day.csv
level_data/2021/01/02/day.csv
level_data/2021/01/03/day.csv
level_data/2021/01/04/day.csv
level_data/2021/01/05/day.csv
level_data/2021/01/06/day.csv
level_data/2021/01/07/day.csv
level_data/2021/01/08/day.csv
level_data/2021/01/09/day.csv
level_data/2021/01/10/day.csv
level_data/2021/01/11/day.csv
level_data/2021/01/12/day.csv
level_data/2021/01/13/day.csv
level_data/2021/01/14/day.csv
level_data/2021/01/15/day.csv
level_data/2021/01/16/day.csv
level_data/2021/01/17/day.csv
level_data/2021/01/18/day.csv
level_data/2021/01/19/day.csv
level_data/2021/01/20/day.csv
level_data/2021/01/21/day.csv
level_data/2021/01/22/day.csv
level_data/2021/01/23/day.csv
level_data/2021/01/24/day.csv
level_data/2021/01/25/day.csv
level_data/2021/01/26/day.csv
level_data/2021/01/27/day.csv
level_data/2021/01/28/day.csv
level_data/2021/01/29/day.csv
level_data/2021/01/30/day.csv
level_data/2021/01/month.csv
level_data/2021/02/01/day.csv
level_data/2021/02/02/day.csv
level_data/2021/02/03/day.csv
level_data/2021/02/04/day.csv
level_data/2021/02/05/day.csv
level_data/2021/02/06/day.csv
level_data/2021/02/07/day.csv
level_data/2021/02/08/day.csv
level_data/2021/02/09/day.csv
level_data/2021/02/10/day.csv
level_data/2021/02/11/day.csv
level_data/2021/02/12/day.csv
level_data/2021/02/13/day.csv
level_data/2021/02/14/day.csv
level_data/2021/02/15/day.csv
level_data/2021/02/16/day.csv
level_data/2021/02/17/day.csv
level_data/2021/02/18/day.csv
level_data/2021/02/19/day.csv
level_data/2021/02/20/day.csv
level_data/2021/02/21/day.csv
level_data/2021/02/22/day.csv
level_data/2021/02/23/day.csv
level_data/2021/02/24/day.csv
level_data/2021/02/25/day.csv
level_data/2021/02/26/day.csv
level_data/2021/02/27/day.csv
level_data/2021/02/28/day.csv
level_data/2021/02/29/day.csv
level_data/2021/02/30/day.csv
level_data/2021/02/month.csv
level_data/2021/03/01/day.csv
level_data/2021/03/02/day.csv
level_data/2021/03/03/day.csv
level_data/2021/03/04/day.csv
level_data/2021/03/05/day.csv
level_data/2021/03/06/day.csv
level_data/2021/03/07/day.csv
level_data/2021/03/08/day.csv
level_data/2021/03/09/day.csv
level_data/2021/03/10/day.csv
level_data/2021/03/11/day.csv
level_data/2021/03/12/day.csv
level_data/2021/03/13/day.csv
level_data/2021/03/14/day.csv
level_data/2021/03/15/day.csv
level_data/2021/03/16/day.csv
level_data/2021/03/17/day.csv
level_data/2021/03/18/day.csv
level_data/2021/03/19/day.csv
level_data/2021/03/20/day.csv
level_data/2021/03/21/day.csv
level_data/2021/03/22/day.csv
level_data/2021/03/23/day.csv
level_data/2021/03/24/day.csv
level_data/2021/03/25/day.csv
level_data/2021/03/26/day.csv
level_data/2021/03/27/day.csv
level_data/2021/03/28/day.csv
level_data/2021/03/29/day.csv
level_data/2021/03/30/day.csv
level_data/2021/03/month.csv
level_data/2021/04/01/day.csv
level_data/2021/04/02/day.csv
level_data/2021/04/03/day.csv
level_data/2021/04/04/day.csv
level_data/2021/04/05/day.csv
level_data/2021/04/06/day.csv
level_data/2021/04/07/day.csv
level_data/2021/04/08/day.csv
level_data/2021/04/09/day.csv
level_data/2021/04/10/day.csv
level_data/2021/04/11/day.csv
level_data/2021/04/12/day.csv
level_data/2021/04/13/day.csv
level_data/2021/04/14/day.csv
level_data/2021/04/15/day.csv
level_data/2021/04/16/day.csv
level_data/2021/04/17/day.csv
level_data/2021/04/18/day.csv
level_data/2021/04/19/day.csv
level_data/2021/04/20/day.csv
level_data/2021/04/21/day.csv
level_data/2021/04/22/day.csv
level_data/2021/04/23/day.csv
level_data/2021/04/24/day.csv
level_data/2021/04/25/day.csv
level_data/2021/04/26/day.csv
level_data/2021/04/27/day.csv
level_data/2021/04/28/day.csv
level_data/2021/04/29/day.csv
level_data/2021/04/30/day.csv
level_data/2021/04/month.csv
level_data/2021/05/01/day.csv
level_data/2021/05/02/day.csv
level_data/2021/05/03/day.csv
level_data/2021/05/04/day.csv
level_data/2021/05/05/day.csv
level_data/2021/05/06/day.csv
level_data/2021/05/07/day.csv
level_data/2021/05/08/day.csv
level_data/2021/05/09/day.csv
level_data/2021/05/10/day.csv
level_data/2021/05/11/day.csv
level_data/2021/05/12/day.csv
level_data/2021/05/13/day.csv
level_data/2021/05/14/day.csv
level_data/2021/05/15/day.csv
level_data/2021/05/16/day.csv
level_data/2021/05/17/day.csv
level_data/2021/05/18/day.csv
level_data/2021/05/19/day.csv
level_data/2021/05/20/day.csv
level_data/2021/05/21/day.csv
level_data/2021/05/22/day.csv
level_data/2021/05/23/day.csv
level_data/2021/05/24/day.csv
level_data/2021/05/25/day.csv
level_data/2021/05/26/day.csv
level_data/2021/05/27/day.csv
level_data/2021/05/28/day.csv
level_data/2021/05/29/day.csv
level_data/2021/05/30/day.csv
level_data/2021/05/month.csv
level_data/2021/06/01/day.csv
level_data/2021/06/02/day.csv
level_data/2021/06/03/day.csv
level_data/2021/06/04/day.csv
level_data/2021/06/05/day.csv
level_data/2021/06/06/day.csv
level_data/2021/06/07/day.csv
level_data/2021/06/08/day.csv
level_data/2021/06/09/day.csv
level_data/2021/06/10/day.csv
level_data/2021/06/11/day.csv
level_data/2021/06/12/day.csv
level_data/2021/06/13/day.csv
level_data/2021/06/14/day.csv
level_data/2021/06/15/day.csv
level_data/2021/06/16/day.csv
level_data/2021/06/17/day.csv
level_data/2021/06/18/day.csv
level_data/2021/06/19/day.csv
level_data/2021/06/20/day.csv
level_data/2021/06/21/day.csv
level_data/2021/06/22/day.csv
level_data/2021/06/23/day.csv
level_data/2021/06/24/day.csv
level_data/2021/06/25/day.csv
level_data/2021/06/26/day.csv
level_data/2021/06/27/day.csv
level_data/2021/06/28/day.csv
level_data/2021/06/29/day.csv
level_data/2021/06/30/day.csv
level_data/2021/06/month.csv
level_data/2021/07/01/day.csv
level_data/2021/07/02/day.csv
level_data/2021/07/03/day.csv
level_data/2021/07/04/day.csv
level_data/2021/07/05/day.csv
level_data/2021/07/06/day.csv
level_data/2021/07/07/day.csv
level_data/2021/07/08/day.csv
level_data/2021/07/09/day.csv
level_data/2021/07/10/day.csv
level_data/2021/07/11/day.csv
level_data/2021/07/12/day.csv
level_data/2021/07/13/day.csv
level_data/2021/07/14/day.csv
level_data/2021/07/15/day.csv
level_data/2021/07/16/day.csv
level_data/2021/07/17/day.csv
level_data/2021/07/18/day.csv
level_data/2021/07/19/day.csv
level_data/2021/07/20/day.csv
level_data/2021/07/21/day.csv
level_data/2021/07/22/day.csv
level_data/2021/07/23/day.csv
level_data/2021/07/24/day.csv
level_data/2021/07/25/day.csv
level_data/2021/07/26/day.csv
level_data/2021/07/27/day.csv
level_data/2021/07/28/day.csv
level_data/2021/07/29/day.csv
level_data/2021/07/30/day.csv
level_data/2021/07/month.csv
level_data/2021/08/01/day.csv
level_data/2021/08/02/day.csv
level_data/2021/08/03/day.csv
level_data/2021/08/04/day.csv
level_data/2021/08/05/day.csv
level_data/2021/08/06/day.csv
level_data/2021/08/07/day.csv
level_data/2021/08/08/day.csv
level_data/2021/08/09/day.csv
level_data/2021/08/10/day.csv
level_data/2021/08/11/day.csv
level_data/2021/08/12/day.csv
level_data/2021/08/13/day.csv
level_data/2021/08/14/day.csv
level_data/2021/08/15/day.csv
level_data/2021/08/16/day.csv
level_data/2021/08/17/day.csv
level_data/2021/08/18/day.csv
level_data/2021/08/19/day.csv
level_data/2021/08/20/day.csv
level_data/2021/08/21/day.csv
level_data/2021/08/22/day.csv
level_data/2021/08/23/day.csv
level_data/2021/08/24/day.csv
level_data/2021/08/25/day.csv
level_data/2021/08/26/day.csv
level_data/2021/08/27/day.csv
level_data/2021/08/28/day.csv
level_data/2021/08/29/day.csv
level_data/2021/08/30/day.csv
level_data/2021/08/month.csv
level_data/2021/09/01/day.csv
level_data/2021/09/02/day.csv
level_data/2021/09/03/day.csv
level_data/2021/09/04/day.csv
level_data/2021/09/05/day.csv
level_data/2021/09/06/day.csv
level_data/2021/09/07/day.csv
level_data/2021/09/08/day.csv
level_data/2021/09/09/day.csv
level_data/2021/09/10/day.csv
level_data/2021/09/11/day.csv
level_data/2021/09/12/day.csv
level_data/2021/09/13/day.csv
level_data/2021/09/14/day.csv
level_data/2021/09/15/day.csv
level_data/2021/09/16/day.csv
level_data/2021/09/17/day.csv
level_data/2021/09/18/day.csv
level_data/2021/09/19/day.csv
level_data/2021/09/20/day.csv
level_data/2021/09/21/day.csv
level_data/2021/09/22/day.csv
level_data/2021/09/23/day.csv
level_data/2021/09/24/day.csv
level_data/2021/09/25/day.csv
level_data/2021/09/26/day.csv
level_data/2021/09/27/day.csv
level_data/2021/09/28/day.csv
level_data/2021/09/29/day.csv
level_data/2021/09/30/day.csv
level_data/2021/09/month.csv
level_data/2021/10/01/day.csv
level_data/2021/10/02/day.csv
level_data/2021/10/03/day.csv
level_data/2021/10/04/day.csv
level_data/2021/10/05/day.csv
level_data/2021/10/06/day.csv
level_data/2021/10/07/day.csv
level_data/2021/10/08/day.csv
level_data/2021/10/09/day.csv
level_data/2021/10/10/day.csv
level_data/2021/10/11/day.csv
level_data/2021/10/12/day.csv
level_data/2021/10/13/day.csv
level_data/2021/10/14/day.csv
level_data/2021/10/15/day.csv
level_data/2021/10/16/day.csv
level_data/2021/10/17/day.csv
level_data/2021/10/18/day.csv
level_data/2021/10/19/day.csv
level_data/2021/10/20/day.csv
level_data/2021/10/21/day.csv
level_data/2021/10/22/day.csv
level_data/2021/10/23/day.csv
level_data/2021/10/24/day.csv
level_data/2021/10/25/day.csv
level_data/2021/10/26/day.csv
level_data/2021/10/27/day.csv
level_data/2021/10/28/day.csv
level_data/2021/10/29/day.csv
level_data/2021/10/30/day.csv
level_data/2021/10/month.csv
level_data/2021/11/01/day.csv
level_data/2021/11/02/day.csv
level_data/2021/11/03/day.csv
level_data/2021/11/04/day.csv
level_data/2021/11/05/day.csv
level_data/2021/11/06/day.csv
level_data/2021/11/07/day.csv
level_data/2021/11/08/day.csv
level_data/2021/11/09/day.csv
level_data/2021/11/10/day.csv
level_data/2021/11/11/day.csv
level_data/2021/11/12/day.csv
level_data/2021/11/13/day.csv
level_data/2021/11/14/day.csv
level_data/2021/11/15/day.csv
level_data/2021/11/16/day.csv
level_data/2021/11/17/day.csv
level_data/2021/11/18/day.csv
level_data/2021/11/19/day.csv
level_data/2021/11/20/day.csv
level_data/2021/11/21/day.csv
level_data/2021/11/22/day.csv
level_data/2021/11/23/day.csv
level_data/2021/11/24/day.csv
level_data/2021/11/25/day.csv
level_data/2021/11/26/day.csv
level_data/2021/11/27/day.csv
level_data/2021/11/28/day.csv
level_data/2021/11/29/day.csv
level_data/2021/11/30/day.csv
level_data/2021/11/month.csv
level_data/2021/12/01/day.csv
level_data/2021/12/02/day.csv
level_data/2021/12/03/day.csv
level_data/2021/12/04/day.csv
level_data/2021/12/05/day.csv
level_data/2021/12/06/day.csv
level_data/2021/12/07/day.csv
level_data/2021/12/08/day.csv
level_data/2021/12/09/day.csv
level_data/2021/12/10/day.csv
level_data/2021/12/11/day.csv
level_data/2021/12/12/day.csv
level_data/2021/12/13/day.csv
level_data/2021/12/14/day.csv
level_data/2021/12/15/day.csv
level_data/2021/12/16/day.csv
level_data/2021/12/17/day.csv
level_data/2021/12/18/day.csv
level_data/2021/12/19/day.csv
level_data/2021/12/20/day.csv
level_data/2021/12/21/day.csv
level_data/2021/12/22/day.csv
level_data/2021/12/23/day.csv
level_data/2021/12/24/day.csv
level_data/2021/12/25/day.csv
level_data/2021/12/26/day.csv
level_data/2021/12/27/day.csv
level_data/2021/12/28/day.csv
level_data/2021/12/29/day.csv
level_data/2021/12/30/day.csv
level_data/2021/12/month.csv
level_data/2021/year.csv

Exercise: Write a version of walk_gen called walk_dfs that traverses the given directory and yields the file it contains, but it should use a stack and run iteratively, rather than recursively.

You can use the following loop to test your code.

for path in walk_dfs(year_dir):
    print(path)
level_data/2021/year.csv
level_data/2021/12/month.csv
level_data/2021/12/30/day.csv
level_data/2021/12/29/day.csv
level_data/2021/12/28/day.csv
level_data/2021/12/27/day.csv
level_data/2021/12/26/day.csv
level_data/2021/12/25/day.csv
level_data/2021/12/24/day.csv
level_data/2021/12/23/day.csv
level_data/2021/12/22/day.csv
level_data/2021/12/21/day.csv
level_data/2021/12/20/day.csv
level_data/2021/12/19/day.csv
level_data/2021/12/18/day.csv
level_data/2021/12/17/day.csv
level_data/2021/12/16/day.csv
level_data/2021/12/15/day.csv
level_data/2021/12/14/day.csv
level_data/2021/12/13/day.csv
level_data/2021/12/12/day.csv
level_data/2021/12/11/day.csv
level_data/2021/12/10/day.csv
level_data/2021/12/09/day.csv
level_data/2021/12/08/day.csv
level_data/2021/12/07/day.csv
level_data/2021/12/06/day.csv
level_data/2021/12/05/day.csv
level_data/2021/12/04/day.csv
level_data/2021/12/03/day.csv
level_data/2021/12/02/day.csv
level_data/2021/12/01/day.csv
level_data/2021/11/month.csv
level_data/2021/11/30/day.csv
level_data/2021/11/29/day.csv
level_data/2021/11/28/day.csv
level_data/2021/11/27/day.csv
level_data/2021/11/26/day.csv
level_data/2021/11/25/day.csv
level_data/2021/11/24/day.csv
level_data/2021/11/23/day.csv
level_data/2021/11/22/day.csv
level_data/2021/11/21/day.csv
level_data/2021/11/20/day.csv
level_data/2021/11/19/day.csv
level_data/2021/11/18/day.csv
level_data/2021/11/17/day.csv
level_data/2021/11/16/day.csv
level_data/2021/11/15/day.csv
level_data/2021/11/14/day.csv
level_data/2021/11/13/day.csv
level_data/2021/11/12/day.csv
level_data/2021/11/11/day.csv
level_data/2021/11/10/day.csv
level_data/2021/11/09/day.csv
level_data/2021/11/08/day.csv
level_data/2021/11/07/day.csv
level_data/2021/11/06/day.csv
level_data/2021/11/05/day.csv
level_data/2021/11/04/day.csv
level_data/2021/11/03/day.csv
level_data/2021/11/02/day.csv
level_data/2021/11/01/day.csv
level_data/2021/10/month.csv
level_data/2021/10/30/day.csv
level_data/2021/10/29/day.csv
level_data/2021/10/28/day.csv
level_data/2021/10/27/day.csv
level_data/2021/10/26/day.csv
level_data/2021/10/25/day.csv
level_data/2021/10/24/day.csv
level_data/2021/10/23/day.csv
level_data/2021/10/22/day.csv
level_data/2021/10/21/day.csv
level_data/2021/10/20/day.csv
level_data/2021/10/19/day.csv
level_data/2021/10/18/day.csv
level_data/2021/10/17/day.csv
level_data/2021/10/16/day.csv
level_data/2021/10/15/day.csv
level_data/2021/10/14/day.csv
level_data/2021/10/13/day.csv
level_data/2021/10/12/day.csv
level_data/2021/10/11/day.csv
level_data/2021/10/10/day.csv
level_data/2021/10/09/day.csv
level_data/2021/10/08/day.csv
level_data/2021/10/07/day.csv
level_data/2021/10/06/day.csv
level_data/2021/10/05/day.csv
level_data/2021/10/04/day.csv
level_data/2021/10/03/day.csv
level_data/2021/10/02/day.csv
level_data/2021/10/01/day.csv
level_data/2021/09/month.csv
level_data/2021/09/30/day.csv
level_data/2021/09/29/day.csv
level_data/2021/09/28/day.csv
level_data/2021/09/27/day.csv
level_data/2021/09/26/day.csv
level_data/2021/09/25/day.csv
level_data/2021/09/24/day.csv
level_data/2021/09/23/day.csv
level_data/2021/09/22/day.csv
level_data/2021/09/21/day.csv
level_data/2021/09/20/day.csv
level_data/2021/09/19/day.csv
level_data/2021/09/18/day.csv
level_data/2021/09/17/day.csv
level_data/2021/09/16/day.csv
level_data/2021/09/15/day.csv
level_data/2021/09/14/day.csv
level_data/2021/09/13/day.csv
level_data/2021/09/12/day.csv
level_data/2021/09/11/day.csv
level_data/2021/09/10/day.csv
level_data/2021/09/09/day.csv
level_data/2021/09/08/day.csv
level_data/2021/09/07/day.csv
level_data/2021/09/06/day.csv
level_data/2021/09/05/day.csv
level_data/2021/09/04/day.csv
level_data/2021/09/03/day.csv
level_data/2021/09/02/day.csv
level_data/2021/09/01/day.csv
level_data/2021/08/month.csv
level_data/2021/08/30/day.csv
level_data/2021/08/29/day.csv
level_data/2021/08/28/day.csv
level_data/2021/08/27/day.csv
level_data/2021/08/26/day.csv
level_data/2021/08/25/day.csv
level_data/2021/08/24/day.csv
level_data/2021/08/23/day.csv
level_data/2021/08/22/day.csv
level_data/2021/08/21/day.csv
level_data/2021/08/20/day.csv
level_data/2021/08/19/day.csv
level_data/2021/08/18/day.csv
level_data/2021/08/17/day.csv
level_data/2021/08/16/day.csv
level_data/2021/08/15/day.csv
level_data/2021/08/14/day.csv
level_data/2021/08/13/day.csv
level_data/2021/08/12/day.csv
level_data/2021/08/11/day.csv
level_data/2021/08/10/day.csv
level_data/2021/08/09/day.csv
level_data/2021/08/08/day.csv
level_data/2021/08/07/day.csv
level_data/2021/08/06/day.csv
level_data/2021/08/05/day.csv
level_data/2021/08/04/day.csv
level_data/2021/08/03/day.csv
level_data/2021/08/02/day.csv
level_data/2021/08/01/day.csv
level_data/2021/07/month.csv
level_data/2021/07/30/day.csv
level_data/2021/07/29/day.csv
level_data/2021/07/28/day.csv
level_data/2021/07/27/day.csv
level_data/2021/07/26/day.csv
level_data/2021/07/25/day.csv
level_data/2021/07/24/day.csv
level_data/2021/07/23/day.csv
level_data/2021/07/22/day.csv
level_data/2021/07/21/day.csv
level_data/2021/07/20/day.csv
level_data/2021/07/19/day.csv
level_data/2021/07/18/day.csv
level_data/2021/07/17/day.csv
level_data/2021/07/16/day.csv
level_data/2021/07/15/day.csv
level_data/2021/07/14/day.csv
level_data/2021/07/13/day.csv
level_data/2021/07/12/day.csv
level_data/2021/07/11/day.csv
level_data/2021/07/10/day.csv
level_data/2021/07/09/day.csv
level_data/2021/07/08/day.csv
level_data/2021/07/07/day.csv
level_data/2021/07/06/day.csv
level_data/2021/07/05/day.csv
level_data/2021/07/04/day.csv
level_data/2021/07/03/day.csv
level_data/2021/07/02/day.csv
level_data/2021/07/01/day.csv
level_data/2021/06/month.csv
level_data/2021/06/30/day.csv
level_data/2021/06/29/day.csv
level_data/2021/06/28/day.csv
level_data/2021/06/27/day.csv
level_data/2021/06/26/day.csv
level_data/2021/06/25/day.csv
level_data/2021/06/24/day.csv
level_data/2021/06/23/day.csv
level_data/2021/06/22/day.csv
level_data/2021/06/21/day.csv
level_data/2021/06/20/day.csv
level_data/2021/06/19/day.csv
level_data/2021/06/18/day.csv
level_data/2021/06/17/day.csv
level_data/2021/06/16/day.csv
level_data/2021/06/15/day.csv
level_data/2021/06/14/day.csv
level_data/2021/06/13/day.csv
level_data/2021/06/12/day.csv
level_data/2021/06/11/day.csv
level_data/2021/06/10/day.csv
level_data/2021/06/09/day.csv
level_data/2021/06/08/day.csv
level_data/2021/06/07/day.csv
level_data/2021/06/06/day.csv
level_data/2021/06/05/day.csv
level_data/2021/06/04/day.csv
level_data/2021/06/03/day.csv
level_data/2021/06/02/day.csv
level_data/2021/06/01/day.csv
level_data/2021/05/month.csv
level_data/2021/05/30/day.csv
level_data/2021/05/29/day.csv
level_data/2021/05/28/day.csv
level_data/2021/05/27/day.csv
level_data/2021/05/26/day.csv
level_data/2021/05/25/day.csv
level_data/2021/05/24/day.csv
level_data/2021/05/23/day.csv
level_data/2021/05/22/day.csv
level_data/2021/05/21/day.csv
level_data/2021/05/20/day.csv
level_data/2021/05/19/day.csv
level_data/2021/05/18/day.csv
level_data/2021/05/17/day.csv
level_data/2021/05/16/day.csv
level_data/2021/05/15/day.csv
level_data/2021/05/14/day.csv
level_data/2021/05/13/day.csv
level_data/2021/05/12/day.csv
level_data/2021/05/11/day.csv
level_data/2021/05/10/day.csv
level_data/2021/05/09/day.csv
level_data/2021/05/08/day.csv
level_data/2021/05/07/day.csv
level_data/2021/05/06/day.csv
level_data/2021/05/05/day.csv
level_data/2021/05/04/day.csv
level_data/2021/05/03/day.csv
level_data/2021/05/02/day.csv
level_data/2021/05/01/day.csv
level_data/2021/04/month.csv
level_data/2021/04/30/day.csv
level_data/2021/04/29/day.csv
level_data/2021/04/28/day.csv
level_data/2021/04/27/day.csv
level_data/2021/04/26/day.csv
level_data/2021/04/25/day.csv
level_data/2021/04/24/day.csv
level_data/2021/04/23/day.csv
level_data/2021/04/22/day.csv
level_data/2021/04/21/day.csv
level_data/2021/04/20/day.csv
level_data/2021/04/19/day.csv
level_data/2021/04/18/day.csv
level_data/2021/04/17/day.csv
level_data/2021/04/16/day.csv
level_data/2021/04/15/day.csv
level_data/2021/04/14/day.csv
level_data/2021/04/13/day.csv
level_data/2021/04/12/day.csv
level_data/2021/04/11/day.csv
level_data/2021/04/10/day.csv
level_data/2021/04/09/day.csv
level_data/2021/04/08/day.csv
level_data/2021/04/07/day.csv
level_data/2021/04/06/day.csv
level_data/2021/04/05/day.csv
level_data/2021/04/04/day.csv
level_data/2021/04/03/day.csv
level_data/2021/04/02/day.csv
level_data/2021/04/01/day.csv
level_data/2021/03/month.csv
level_data/2021/03/30/day.csv
level_data/2021/03/29/day.csv
level_data/2021/03/28/day.csv
level_data/2021/03/27/day.csv
level_data/2021/03/26/day.csv
level_data/2021/03/25/day.csv
level_data/2021/03/24/day.csv
level_data/2021/03/23/day.csv
level_data/2021/03/22/day.csv
level_data/2021/03/21/day.csv
level_data/2021/03/20/day.csv
level_data/2021/03/19/day.csv
level_data/2021/03/18/day.csv
level_data/2021/03/17/day.csv
level_data/2021/03/16/day.csv
level_data/2021/03/15/day.csv
level_data/2021/03/14/day.csv
level_data/2021/03/13/day.csv
level_data/2021/03/12/day.csv
level_data/2021/03/11/day.csv
level_data/2021/03/10/day.csv
level_data/2021/03/09/day.csv
level_data/2021/03/08/day.csv
level_data/2021/03/07/day.csv
level_data/2021/03/06/day.csv
level_data/2021/03/05/day.csv
level_data/2021/03/04/day.csv
level_data/2021/03/03/day.csv
level_data/2021/03/02/day.csv
level_data/2021/03/01/day.csv
level_data/2021/02/month.csv
level_data/2021/02/30/day.csv
level_data/2021/02/29/day.csv
level_data/2021/02/28/day.csv
level_data/2021/02/27/day.csv
level_data/2021/02/26/day.csv
level_data/2021/02/25/day.csv
level_data/2021/02/24/day.csv
level_data/2021/02/23/day.csv
level_data/2021/02/22/day.csv
level_data/2021/02/21/day.csv
level_data/2021/02/20/day.csv
level_data/2021/02/19/day.csv
level_data/2021/02/18/day.csv
level_data/2021/02/17/day.csv
level_data/2021/02/16/day.csv
level_data/2021/02/15/day.csv
level_data/2021/02/14/day.csv
level_data/2021/02/13/day.csv
level_data/2021/02/12/day.csv
level_data/2021/02/11/day.csv
level_data/2021/02/10/day.csv
level_data/2021/02/09/day.csv
level_data/2021/02/08/day.csv
level_data/2021/02/07/day.csv
level_data/2021/02/06/day.csv
level_data/2021/02/05/day.csv
level_data/2021/02/04/day.csv
level_data/2021/02/03/day.csv
level_data/2021/02/02/day.csv
level_data/2021/02/01/day.csv
level_data/2021/01/month.csv
level_data/2021/01/30/day.csv
level_data/2021/01/29/day.csv
level_data/2021/01/28/day.csv
level_data/2021/01/27/day.csv
level_data/2021/01/26/day.csv
level_data/2021/01/25/day.csv
level_data/2021/01/24/day.csv
level_data/2021/01/23/day.csv
level_data/2021/01/22/day.csv
level_data/2021/01/21/day.csv
level_data/2021/01/20/day.csv
level_data/2021/01/19/day.csv
level_data/2021/01/18/day.csv
level_data/2021/01/17/day.csv
level_data/2021/01/16/day.csv
level_data/2021/01/15/day.csv
level_data/2021/01/14/day.csv
level_data/2021/01/13/day.csv
level_data/2021/01/12/day.csv
level_data/2021/01/11/day.csv
level_data/2021/01/10/day.csv
level_data/2021/01/09/day.csv
level_data/2021/01/08/day.csv
level_data/2021/01/07/day.csv
level_data/2021/01/06/day.csv
level_data/2021/01/05/day.csv
level_data/2021/01/04/day.csv
level_data/2021/01/03/day.csv
level_data/2021/01/02/day.csv
level_data/2021/01/01/day.csv
level_data/2021/00/month.csv
level_data/2021/00/30/day.csv
level_data/2021/00/29/day.csv
level_data/2021/00/28/day.csv
level_data/2021/00/27/day.csv
level_data/2021/00/26/day.csv
level_data/2021/00/25/day.csv
level_data/2021/00/24/day.csv
level_data/2021/00/23/day.csv
level_data/2021/00/22/day.csv
level_data/2021/00/21/day.csv
level_data/2021/00/20/day.csv
level_data/2021/00/19/day.csv
level_data/2021/00/18/day.csv
level_data/2021/00/17/day.csv
level_data/2021/00/16/day.csv
level_data/2021/00/15/day.csv
level_data/2021/00/14/day.csv
level_data/2021/00/13/day.csv
level_data/2021/00/12/day.csv
level_data/2021/00/11/day.csv
level_data/2021/00/10/day.csv
level_data/2021/00/09/day.csv
level_data/2021/00/08/day.csv
level_data/2021/00/07/day.csv
level_data/2021/00/06/day.csv
level_data/2021/00/05/day.csv
level_data/2021/00/04/day.csv
level_data/2021/00/03/day.csv
level_data/2021/00/02/day.csv
level_data/2021/00/01/day.csv

Notice that the order the files are discovered is “depth-first”. For example, it yields all files from the first month before any of the files for the second month.

An alternative is a level-order traversal, which yields all files at the first level (the annual summary), then all the files at the second level (the monthly summaries), then the files at the third level.

To implement a level-order traversal, we can make a minimal change to walk_dfs: replace the stack with a FIFO queue. To implement the queue efficiently, we can use collections.deque.

Exercise: Write a generator function called walk_level that takes a directory and yields its files in level order.

Use the following loop to test your code.

for path in walk_level(year_dir):
    print(path)
level_data/2021/year.csv
level_data/2021/00/month.csv
level_data/2021/01/month.csv
level_data/2021/02/month.csv
level_data/2021/03/month.csv
level_data/2021/04/month.csv
level_data/2021/05/month.csv
level_data/2021/06/month.csv
level_data/2021/07/month.csv
level_data/2021/08/month.csv
level_data/2021/09/month.csv
level_data/2021/10/month.csv
level_data/2021/11/month.csv
level_data/2021/12/month.csv
level_data/2021/00/01/day.csv
level_data/2021/00/02/day.csv
level_data/2021/00/03/day.csv
level_data/2021/00/04/day.csv
level_data/2021/00/05/day.csv
level_data/2021/00/06/day.csv
level_data/2021/00/07/day.csv
level_data/2021/00/08/day.csv
level_data/2021/00/09/day.csv
level_data/2021/00/10/day.csv
level_data/2021/00/11/day.csv
level_data/2021/00/12/day.csv
level_data/2021/00/13/day.csv
level_data/2021/00/14/day.csv
level_data/2021/00/15/day.csv
level_data/2021/00/16/day.csv
level_data/2021/00/17/day.csv
level_data/2021/00/18/day.csv
level_data/2021/00/19/day.csv
level_data/2021/00/20/day.csv
level_data/2021/00/21/day.csv
level_data/2021/00/22/day.csv
level_data/2021/00/23/day.csv
level_data/2021/00/24/day.csv
level_data/2021/00/25/day.csv
level_data/2021/00/26/day.csv
level_data/2021/00/27/day.csv
level_data/2021/00/28/day.csv
level_data/2021/00/29/day.csv
level_data/2021/00/30/day.csv
level_data/2021/01/01/day.csv
level_data/2021/01/02/day.csv
level_data/2021/01/03/day.csv
level_data/2021/01/04/day.csv
level_data/2021/01/05/day.csv
level_data/2021/01/06/day.csv
level_data/2021/01/07/day.csv
level_data/2021/01/08/day.csv
level_data/2021/01/09/day.csv
level_data/2021/01/10/day.csv
level_data/2021/01/11/day.csv
level_data/2021/01/12/day.csv
level_data/2021/01/13/day.csv
level_data/2021/01/14/day.csv
level_data/2021/01/15/day.csv
level_data/2021/01/16/day.csv
level_data/2021/01/17/day.csv
level_data/2021/01/18/day.csv
level_data/2021/01/19/day.csv
level_data/2021/01/20/day.csv
level_data/2021/01/21/day.csv
level_data/2021/01/22/day.csv
level_data/2021/01/23/day.csv
level_data/2021/01/24/day.csv
level_data/2021/01/25/day.csv
level_data/2021/01/26/day.csv
level_data/2021/01/27/day.csv
level_data/2021/01/28/day.csv
level_data/2021/01/29/day.csv
level_data/2021/01/30/day.csv
level_data/2021/02/01/day.csv
level_data/2021/02/02/day.csv
level_data/2021/02/03/day.csv
level_data/2021/02/04/day.csv
level_data/2021/02/05/day.csv
level_data/2021/02/06/day.csv
level_data/2021/02/07/day.csv
level_data/2021/02/08/day.csv
level_data/2021/02/09/day.csv
level_data/2021/02/10/day.csv
level_data/2021/02/11/day.csv
level_data/2021/02/12/day.csv
level_data/2021/02/13/day.csv
level_data/2021/02/14/day.csv
level_data/2021/02/15/day.csv
level_data/2021/02/16/day.csv
level_data/2021/02/17/day.csv
level_data/2021/02/18/day.csv
level_data/2021/02/19/day.csv
level_data/2021/02/20/day.csv
level_data/2021/02/21/day.csv
level_data/2021/02/22/day.csv
level_data/2021/02/23/day.csv
level_data/2021/02/24/day.csv
level_data/2021/02/25/day.csv
level_data/2021/02/26/day.csv
level_data/2021/02/27/day.csv
level_data/2021/02/28/day.csv
level_data/2021/02/29/day.csv
level_data/2021/02/30/day.csv
level_data/2021/03/01/day.csv
level_data/2021/03/02/day.csv
level_data/2021/03/03/day.csv
level_data/2021/03/04/day.csv
level_data/2021/03/05/day.csv
level_data/2021/03/06/day.csv
level_data/2021/03/07/day.csv
level_data/2021/03/08/day.csv
level_data/2021/03/09/day.csv
level_data/2021/03/10/day.csv
level_data/2021/03/11/day.csv
level_data/2021/03/12/day.csv
level_data/2021/03/13/day.csv
level_data/2021/03/14/day.csv
level_data/2021/03/15/day.csv
level_data/2021/03/16/day.csv
level_data/2021/03/17/day.csv
level_data/2021/03/18/day.csv
level_data/2021/03/19/day.csv
level_data/2021/03/20/day.csv
level_data/2021/03/21/day.csv
level_data/2021/03/22/day.csv
level_data/2021/03/23/day.csv
level_data/2021/03/24/day.csv
level_data/2021/03/25/day.csv
level_data/2021/03/26/day.csv
level_data/2021/03/27/day.csv
level_data/2021/03/28/day.csv
level_data/2021/03/29/day.csv
level_data/2021/03/30/day.csv
level_data/2021/04/01/day.csv
level_data/2021/04/02/day.csv
level_data/2021/04/03/day.csv
level_data/2021/04/04/day.csv
level_data/2021/04/05/day.csv
level_data/2021/04/06/day.csv
level_data/2021/04/07/day.csv
level_data/2021/04/08/day.csv
level_data/2021/04/09/day.csv
level_data/2021/04/10/day.csv
level_data/2021/04/11/day.csv
level_data/2021/04/12/day.csv
level_data/2021/04/13/day.csv
level_data/2021/04/14/day.csv
level_data/2021/04/15/day.csv
level_data/2021/04/16/day.csv
level_data/2021/04/17/day.csv
level_data/2021/04/18/day.csv
level_data/2021/04/19/day.csv
level_data/2021/04/20/day.csv
level_data/2021/04/21/day.csv
level_data/2021/04/22/day.csv
level_data/2021/04/23/day.csv
level_data/2021/04/24/day.csv
level_data/2021/04/25/day.csv
level_data/2021/04/26/day.csv
level_data/2021/04/27/day.csv
level_data/2021/04/28/day.csv
level_data/2021/04/29/day.csv
level_data/2021/04/30/day.csv
level_data/2021/05/01/day.csv
level_data/2021/05/02/day.csv
level_data/2021/05/03/day.csv
level_data/2021/05/04/day.csv
level_data/2021/05/05/day.csv
level_data/2021/05/06/day.csv
level_data/2021/05/07/day.csv
level_data/2021/05/08/day.csv
level_data/2021/05/09/day.csv
level_data/2021/05/10/day.csv
level_data/2021/05/11/day.csv
level_data/2021/05/12/day.csv
level_data/2021/05/13/day.csv
level_data/2021/05/14/day.csv
level_data/2021/05/15/day.csv
level_data/2021/05/16/day.csv
level_data/2021/05/17/day.csv
level_data/2021/05/18/day.csv
level_data/2021/05/19/day.csv
level_data/2021/05/20/day.csv
level_data/2021/05/21/day.csv
level_data/2021/05/22/day.csv
level_data/2021/05/23/day.csv
level_data/2021/05/24/day.csv
level_data/2021/05/25/day.csv
level_data/2021/05/26/day.csv
level_data/2021/05/27/day.csv
level_data/2021/05/28/day.csv
level_data/2021/05/29/day.csv
level_data/2021/05/30/day.csv
level_data/2021/06/01/day.csv
level_data/2021/06/02/day.csv
level_data/2021/06/03/day.csv
level_data/2021/06/04/day.csv
level_data/2021/06/05/day.csv
level_data/2021/06/06/day.csv
level_data/2021/06/07/day.csv
level_data/2021/06/08/day.csv
level_data/2021/06/09/day.csv
level_data/2021/06/10/day.csv
level_data/2021/06/11/day.csv
level_data/2021/06/12/day.csv
level_data/2021/06/13/day.csv
level_data/2021/06/14/day.csv
level_data/2021/06/15/day.csv
level_data/2021/06/16/day.csv
level_data/2021/06/17/day.csv
level_data/2021/06/18/day.csv
level_data/2021/06/19/day.csv
level_data/2021/06/20/day.csv
level_data/2021/06/21/day.csv
level_data/2021/06/22/day.csv
level_data/2021/06/23/day.csv
level_data/2021/06/24/day.csv
level_data/2021/06/25/day.csv
level_data/2021/06/26/day.csv
level_data/2021/06/27/day.csv
level_data/2021/06/28/day.csv
level_data/2021/06/29/day.csv
level_data/2021/06/30/day.csv
level_data/2021/07/01/day.csv
level_data/2021/07/02/day.csv
level_data/2021/07/03/day.csv
level_data/2021/07/04/day.csv
level_data/2021/07/05/day.csv
level_data/2021/07/06/day.csv
level_data/2021/07/07/day.csv
level_data/2021/07/08/day.csv
level_data/2021/07/09/day.csv
level_data/2021/07/10/day.csv
level_data/2021/07/11/day.csv
level_data/2021/07/12/day.csv
level_data/2021/07/13/day.csv
level_data/2021/07/14/day.csv
level_data/2021/07/15/day.csv
level_data/2021/07/16/day.csv
level_data/2021/07/17/day.csv
level_data/2021/07/18/day.csv
level_data/2021/07/19/day.csv
level_data/2021/07/20/day.csv
level_data/2021/07/21/day.csv
level_data/2021/07/22/day.csv
level_data/2021/07/23/day.csv
level_data/2021/07/24/day.csv
level_data/2021/07/25/day.csv
level_data/2021/07/26/day.csv
level_data/2021/07/27/day.csv
level_data/2021/07/28/day.csv
level_data/2021/07/29/day.csv
level_data/2021/07/30/day.csv
level_data/2021/08/01/day.csv
level_data/2021/08/02/day.csv
level_data/2021/08/03/day.csv
level_data/2021/08/04/day.csv
level_data/2021/08/05/day.csv
level_data/2021/08/06/day.csv
level_data/2021/08/07/day.csv
level_data/2021/08/08/day.csv
level_data/2021/08/09/day.csv
level_data/2021/08/10/day.csv
level_data/2021/08/11/day.csv
level_data/2021/08/12/day.csv
level_data/2021/08/13/day.csv
level_data/2021/08/14/day.csv
level_data/2021/08/15/day.csv
level_data/2021/08/16/day.csv
level_data/2021/08/17/day.csv
level_data/2021/08/18/day.csv
level_data/2021/08/19/day.csv
level_data/2021/08/20/day.csv
level_data/2021/08/21/day.csv
level_data/2021/08/22/day.csv
level_data/2021/08/23/day.csv
level_data/2021/08/24/day.csv
level_data/2021/08/25/day.csv
level_data/2021/08/26/day.csv
level_data/2021/08/27/day.csv
level_data/2021/08/28/day.csv
level_data/2021/08/29/day.csv
level_data/2021/08/30/day.csv
level_data/2021/09/01/day.csv
level_data/2021/09/02/day.csv
level_data/2021/09/03/day.csv
level_data/2021/09/04/day.csv
level_data/2021/09/05/day.csv
level_data/2021/09/06/day.csv
level_data/2021/09/07/day.csv
level_data/2021/09/08/day.csv
level_data/2021/09/09/day.csv
level_data/2021/09/10/day.csv
level_data/2021/09/11/day.csv
level_data/2021/09/12/day.csv
level_data/2021/09/13/day.csv
level_data/2021/09/14/day.csv
level_data/2021/09/15/day.csv
level_data/2021/09/16/day.csv
level_data/2021/09/17/day.csv
level_data/2021/09/18/day.csv
level_data/2021/09/19/day.csv
level_data/2021/09/20/day.csv
level_data/2021/09/21/day.csv
level_data/2021/09/22/day.csv
level_data/2021/09/23/day.csv
level_data/2021/09/24/day.csv
level_data/2021/09/25/day.csv
level_data/2021/09/26/day.csv
level_data/2021/09/27/day.csv
level_data/2021/09/28/day.csv
level_data/2021/09/29/day.csv
level_data/2021/09/30/day.csv
level_data/2021/10/01/day.csv
level_data/2021/10/02/day.csv
level_data/2021/10/03/day.csv
level_data/2021/10/04/day.csv
level_data/2021/10/05/day.csv
level_data/2021/10/06/day.csv
level_data/2021/10/07/day.csv
level_data/2021/10/08/day.csv
level_data/2021/10/09/day.csv
level_data/2021/10/10/day.csv
level_data/2021/10/11/day.csv
level_data/2021/10/12/day.csv
level_data/2021/10/13/day.csv
level_data/2021/10/14/day.csv
level_data/2021/10/15/day.csv
level_data/2021/10/16/day.csv
level_data/2021/10/17/day.csv
level_data/2021/10/18/day.csv
level_data/2021/10/19/day.csv
level_data/2021/10/20/day.csv
level_data/2021/10/21/day.csv
level_data/2021/10/22/day.csv
level_data/2021/10/23/day.csv
level_data/2021/10/24/day.csv
level_data/2021/10/25/day.csv
level_data/2021/10/26/day.csv
level_data/2021/10/27/day.csv
level_data/2021/10/28/day.csv
level_data/2021/10/29/day.csv
level_data/2021/10/30/day.csv
level_data/2021/11/01/day.csv
level_data/2021/11/02/day.csv
level_data/2021/11/03/day.csv
level_data/2021/11/04/day.csv
level_data/2021/11/05/day.csv
level_data/2021/11/06/day.csv
level_data/2021/11/07/day.csv
level_data/2021/11/08/day.csv
level_data/2021/11/09/day.csv
level_data/2021/11/10/day.csv
level_data/2021/11/11/day.csv
level_data/2021/11/12/day.csv
level_data/2021/11/13/day.csv
level_data/2021/11/14/day.csv
level_data/2021/11/15/day.csv
level_data/2021/11/16/day.csv
level_data/2021/11/17/day.csv
level_data/2021/11/18/day.csv
level_data/2021/11/19/day.csv
level_data/2021/11/20/day.csv
level_data/2021/11/21/day.csv
level_data/2021/11/22/day.csv
level_data/2021/11/23/day.csv
level_data/2021/11/24/day.csv
level_data/2021/11/25/day.csv
level_data/2021/11/26/day.csv
level_data/2021/11/27/day.csv
level_data/2021/11/28/day.csv
level_data/2021/11/29/day.csv
level_data/2021/11/30/day.csv
level_data/2021/12/01/day.csv
level_data/2021/12/02/day.csv
level_data/2021/12/03/day.csv
level_data/2021/12/04/day.csv
level_data/2021/12/05/day.csv
level_data/2021/12/06/day.csv
level_data/2021/12/07/day.csv
level_data/2021/12/08/day.csv
level_data/2021/12/09/day.csv
level_data/2021/12/10/day.csv
level_data/2021/12/11/day.csv
level_data/2021/12/12/day.csv
level_data/2021/12/13/day.csv
level_data/2021/12/14/day.csv
level_data/2021/12/15/day.csv
level_data/2021/12/16/day.csv
level_data/2021/12/17/day.csv
level_data/2021/12/18/day.csv
level_data/2021/12/19/day.csv
level_data/2021/12/20/day.csv
level_data/2021/12/21/day.csv
level_data/2021/12/22/day.csv
level_data/2021/12/23/day.csv
level_data/2021/12/24/day.csv
level_data/2021/12/25/day.csv
level_data/2021/12/26/day.csv
level_data/2021/12/27/day.csv
level_data/2021/12/28/day.csv
level_data/2021/12/29/day.csv
level_data/2021/12/30/day.csv

If you are looking for a file in a large file system, a level-order search might be useful if you think the file is more likely to be near the root, rather than deep in a nested subdirectory.

Data Structures and Information Retrieval in Python

Copyright 2021 Allen Downey

License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International