So, I have this list of files:
input_list = ["folder/1611235550000_chicken.json", "folder/1611235723000_dog.json", "folder/1622235723000_dog.json"]
And I need to find the duplicated animal names and, from there, print the oldest one based on the epoch_timestamp (the one with the smallest timestamp).
The file names always follow the same template: "folder/<epoch_timestamp>_<animal_name>.json".
For the list above, it should print:
"folder/1611235723000_dog.json"
This is what I have so far:
def duplicate(input_list):
return list(set([x for x in input_list if input_list.count(x) > 1]))
if __name__ == '__main__':
input_list = ["folder/1611235550000_chicken.json", "folder/1611235723000_dog.json", "folder/1622235723000_dog.json"]
print(duplicate(input_list))
But this does not return anything because the epoch_timestamps are different.