I am looping through each row (line containing "fields" separated by spaces) inside a data file and would like to compare a substring of one field with another static value. If the comparison is true I would like to print a string 'X' otherwise 'Y'. Just wondering how can it be done using Python. Any help would be appreciated. Thanks.
Code :-
for i in inputm[1:]:
print('\n',i[0].split(':')[0]
,str(datetime.strptime(i[0].split(':')[1],'%Y%m%d'))[:10]
,i[1],round(sum( float(v) if v else 0.0 for v in i[2:6])/4,2)
,i[6][0:23]
)
Input :-
1:20160101 123 10 20 0 0 http://www.google.com/favorites
2:20170101 234 20 30 10 0 http://www.doodle.com/favorites
Output :-
1 2016-01-01 123 7.5 Correct
2 2017-01-01 234 17.5 InCorrect
Comments :- I am really interested in this piece of code.
i[6][0:23]
Would like to compare the above substring with http://www.google.com and if they match then print Correct else InCorrect.