My file directory is full of filenames with "male" and "female" being part of them. I want to loop through the directory and distinguish between the two.
import os
maleDataSets = 0
femaleDataSets = 0
females = []
males = []
filePath = "Dataset/parameter feature vectors"
for file in os.listdir(filePath):
femaleDataSets = file.find("female")
if femaleDataSets == -1:
females.append(femaleDataSets)
print file
else:
males.append(...)
I'd like to be able to say... if femaleDataSets are found, print their filenames - just to show that I am reading the correct files. Not sure if I am searching correctly. Any help would be greatly appreciated!