df = pd.read_csv('data.txt', names=['col1', 'col2', 'col3', 'col4', 'col5',
    'col6'])
print('Given data-set')
print(df)
df['diff'] = df['col4'] - df['col6']
flt = df[(df.col5 == 'A') & (df.col4 > df.col6)]
print('Filtered data-set')
print(flt)
print('sum(col6) = %d' % df.sum(axis=0, numeric_only=True)['col6'])
How to print out specific rows/lines in a text file based on a condition (greater than or less than)