File: class/Extras/Other/PriorClasses/schwab-sep12/awker.py
# awk emulation (column extraction) for val in [line.split()[6] for line in open('input.txt')]: print val # same, but more explicit print '+' * 40 col7 = [] for line in open('input.txt'): cols = line.split() col7.append(cols[6]) for item in col7: print item # reusable function print '+' * 40 def awker(file, col): return [line.rstrip().split()[col-1] for line in open(file)] print awker('input.txt', 7) print ','.join(awker('input.txt', 7))