Last active
February 27, 2018 13:47
-
-
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コマンドを用いよ.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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