def iterdatainfile(filename, spliter='\t'):
with open(filename, 'rt') as handle:
for ln in handle:
yield ln.split(spliter)
focue, LF = 1, '\n'
with open("output.txt", 'wt') as handle:
handle.writelines([row[focue] + LF
for row in iterdatainfile('test.txt',
spliter='|')])
正则表达式就行了