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,[email protected],logfile.log
path/to/app2,app2,success,[email protected],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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…