Created
July 28, 2022 10:39
-
-
Save Codehunter-py/4b4aa1d9d1478f188c70dd3eccf7247d to your computer and use it in GitHub Desktop.
Read the inputFile.txt then write two output files if conditions are matched
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
def fileIO(inputFile='inputFile.txt'): | |
f = open(inputFile,'r') | |
output1 = "PassFile.txt" | |
output2 = "FailFile.txt" | |
passFile = open(output1,'w') | |
failFile = open(output2, 'w') | |
for line in f: | |
line_split = line.split() | |
if line_split[2] == "P": | |
passFile.write(line) | |
elif line_split[2] == 'F': | |
failFile.write(line) | |
else: | |
pass | |
passFile.close() | |
failFile.close() | |
if __name__ == '__main__': | |
fileIO() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment