Im trying to count the number of occurrences of a word in a comma seperated file, using python.
I have a file that contains strings like this:
path/to/app1,app1,fail,my@email.com,logfile.log
path/to/app2,app2,success,my@email.com,logfile.log
I want to find the out how many times "fail" is in the file.
I tried several things including
for line in lines:
if line.split(',') == "fail":
fails += 1
See Question&Answers more detail:os