I'm trying to consider the best way of running through a directory tree and identifying specific excel files, then moving on to manipulating them in pandas.
I tried to identify the files I want by scanning for the names of the files, (data) but I realised it would be far more effective if I was able to identify files by their authors. How would I be able to redo the example below from searching 'data' to searching for the author of the file?
I added file.lower() in my example as some files might contain Data or DATA in the file name. If there is a better way of doing this, and if there is a good resource for learning more about manipulating files as described in my post, I would be grateful to hear about it.
import os
import shutil
for folderName, subfolders, filenames in os.walk(r'dir\Documents'):
for file in filenames:
file.lower()
if 'data' in file:
try: shutil.copy(os.path.join(folderName, file), 'C:\\dir\ALL DATA')
except:
print(folderName, file)