I have a list that contains different paths to files. I want to sort the elements in this list by matching the stem of these paths (i.e. the file name) with a column in a csv file that contains the file names. This is to make sure that the list displays elements in order of the file names that are contained in the csv. The csv is similar to as shown below:
I have done the following:
file_list = ['C:\\Example\\SS\\e342-SFA.jpg', 'C:\\Example\\DF\\j541-DFS.jpg', 'C:\\Example\\SD\\p162-YSA.jpg']
for f in file_list:
x = Path(f).stem # grabs file name from file_list without .jpg
for line in csv_file:
IL = line.replace(":", "").replace("\n", "").replace("(", "").replace(")", "")
columns = IL.split(",")
if columns[3] == x: # column[3] = File name in csv
[do the sorting]
I'm not sure how to proceed further from here.
