python find FAILED numbers in log file
<p>I would like Python code to search for FAILED number from a file.txt .like here 5 ,  i need to search the FAILED number, whether 0 or any number. then i can send an email the number of failures. 
  I have tried the grep  but it does not works. </p>

<pre><code>searchfile = open("file.txt", "r")
for line in searchfile:
    if "FAILED" in line: print line
searchfile.close()


             Total    Copied   Skipped  Mismatch    FAILED    Extras
 Dirs :      2575         0      2575         0         5         0
Files :      6039         0      6039         0         0         0
Bytes :   1.547 g         0   1.547 g         0         0         0
Times :   0:00:53   0:00:00                       0:00:00   0:00:53


    Ended : Tue Aug 30 04:32:48 2016
</code></pre>

<p>You can find the position of the FAILED column and look at the values at that position in the rows of interest: </p>

<pre><code>result = {}
col = 'FAILED'
col_index = None
row_names = {'Dirs', 'Files'}

for l in open('file.txt').readlines():
    if col_index is None:
        if col in l:
            col_index = l.find(col)
    else:
        l_split = l.split()
        if len(l_split) &gt; 0 and l_split[0] in row_names:
            result[l_split[0]] = int(l[col_index:col_index+len(col)])
print(result)
</code></pre>

python windows robocopy