I'm attempting to parse a directory in Python. Below is the code I'm using.
for root, dirs, files in os.walk("Z:\MY_DIRECTORY", topdown=False):
for name in files:
fname = str(os.path.join(root, name))
splitdir = fname.split("\")
I get an error that says, "invalid syntax" error.
I eventually want to write each folder/directory to it's own field in a database. So, I would have a column with the entire path and then several columns that have the individual directory names that make up the path. Am I on the right track, or is there an easier way to do this?