Find filenames in folders and match up to an Excel table
<p>I need to extract file names (drawing numbers) from a given folder and subfolders. Then I need to cross-reference the list of found drawing numbers against an Excel file that contains a list of drawing numbers and corresponding drawing descriptions. The output needs to be an Excel table with two columns, for the drawing number and drawing description. There are about 500 drawings in 20 folders and subfolders that need to be traversed.</p>

<p><code>walk</code> from the <code>os</code> module is probably going to be helpful, as is the <code>csv</code> module for making files excel can read.  Without more details, I can only give you a rough skeleton.  In the following, <code>root</code> is the top-level directory that contains all the directories you want to search:</p>

<pre><code>import os
import csv

#The below is sample code for reading your existing csv files.  
#It will vary based on their exact specifications

with open('myfile.csv', newline='') as f:
    reader = csv.reader(f)
    d = {line[0]: line[1] for line in reader}

#Next is code for opening the output file, 
#then going through all the filenames in our directory
#For each filename, we look it up in the dictionary from earlier
# then write that pair to the output file

with open('output.csv', 'w+', newline='') as out:
    writer = csv.writer(out)
    for dirpath, dirnames, filenames in os.walk('root'):
        for filename in filenames:
            writer.writerow([filename, d[filename])
</code></pre>

<p>I suggest you look up <code>csv</code> and <code>os.walk</code> in the official Python documentation</p>

python excel windows