#!/usr/bin/env python import sys # input comes from STDIN (standard input) for line in sys.stdin: # remove leading and trailing whitespace line = line.strip() # split the line into words words = line.split('|') #we only care about the 6th column word = words[5] # increase counters print '%s\t%s' % (word, 1)