Following up with this question - is there a way to add multiple columns as the output?
Using column value as output path location python
C:/Desktop/main_folder/
file.txt
Bob November folder_1
Jon January folder_3
Sam December folder_1
Jane April folder_2
Modifying it to include columns 2 gives indexerror list out of range. Can you add a third column to the path variable?
with open('file.txt', 'r') as infile:
for line in infile:
columns = line.strip().split()
path = os.path.join('/Desktop/main_folder', columns[2], columns[1])
with open(path, 'w') as outfile:
outfile.write(line)