Skip to content

Instantly share code, notes, and snippets.

@Codehunter-py
Created July 28, 2022 10:39
Show Gist options
  • Save Codehunter-py/4b4aa1d9d1478f188c70dd3eccf7247d to your computer and use it in GitHub Desktop.
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
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