Skip to content

Instantly share code, notes, and snippets.

@c-yan
Last active February 27, 2018 13:47
Show Gist options
  • Save c-yan/250d89af49fb88cd5cecfe84a13c77c5 to your computer and use it in GitHub Desktop.
Save c-yan/250d89af49fb88cd5cecfe84a13c77c5 to your computer and use it in GitHub Desktop.
13. col1.txtとcol2.txtをマージ 12で作ったcol1.txtとcol2.txtを結合し,元のファイルの1列目と2列目をタブ区切りで並べたテキストファイルを作成せよ.確認にはpasteコマンドを用いよ.
#! /usr/bin/python
# -*- coding: utf-8 -*-
from sys import argv, stdout
from itertools import izip
def iterlines(fn):
with open(fn) as f:
for line in f:
yield line.rstrip('\r\n')
for e in izip(*[iterlines(fn) for fn in argv[1:]]):
stdout.write('%s\n' % '\t'.join(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment