I am having an issue with my code. I am trying to print out in numerical order the folder's name while taking in information from that folder's Report.csv
file.
red = []
black = []
orange = []
for x in dirs:
if x[0:3] == "red":
red.append(x)
elif x[0:5] == "black":
black.append(x)
elif x[0:6] == "orange":
orange.append(x)
for x in red:
print(f"{x}:")
try:
df = pd.read_csv(x + "/Report.csv")
df_filter= df[['Start','ID','Name',"Type", "Status", "Info"]]
testFilter = df_filter[(df_filter.Type == 'Test')]
if testFilter['Status'].str.contains('Fail').any():
fullFinalTable= testFilter[['Start','ID','Name', "Info"]]
print(fullFinalTable)
else:
print("No errors.")
except FileNotFoundError:
print("File does not exist")
When doing print(f"{x}:")
I will get the following output
red1
red10
red11
.
.
.
red19
red2
red20
red21
.
.
.
However, I am trying to make sure it is in numerical order (red1, red2, red3...red10, red11, etc)
. I have tried to convert x into a float
and an integer
, however no luck.