I am trying to retrieve files from a folder called ‘dataframes’ and store them into a list by separating them via there station identifier in the filename. However, every time I do it, the lists are empty. Any help would be great.
list1 = []
list2 = []
def get_station(file_name: str):
return re.findall(r'.\d\d.', file_name)
def main():
for filename in os.listdir('dataframes'):
file_path = os.path.join('dataframes', filename)
station = get_station(filename)
if station == '23':
list1.append(file_path)
elif station == '05':
list2.append(file_path)
print(list1)
if __name__ == "__main__":
main()