Created
April 21, 2022 20:23
-
-
Save iaverypadberg/e9a0c49a36e91c32f2fa4955cf333f1f to your computer and use it in GitHub Desktop.
Check the integrity of labels after running the bash.sh script I wrote and piping it to a text file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from re import T | |
labels = ["frodo","sam","legolas","gimli","karim benzema"] | |
# Open a text file to write the bad labels to | |
with open("bad_labels.txt","w") as bad: | |
# Open the text file with all of the data in it | |
with open("test2_xml/test.txt") as file: | |
temp_line = "" | |
for line in file: | |
if("filename" in line): | |
temp_line = line | |
print(temp_line) | |
else: | |
# There is probably a better way to get ahold of the string im interested in | |
line_1_split = line.split(">") | |
line_2_split = line_1_split[1].split("<") | |
if(line_2_split[0].strip() in labels): | |
print(line_2_split[0] + " label okay.") | |
else: | |
bad.write(temp_line) | |
bad.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment