Last active
December 27, 2015 20:49
-
-
Save noexpect/7386850 to your computer and use it in GitHub Desktop.
tab区切りのテキストファイルの1列目をtag(_の前方のみを取得)として残りの列をfloatとして出力
This file contains 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
0000_a 0 1 0 2 | |
0001_b 0 0 3 0 | |
0002_c 0 2 0 0 | |
0003_d 1 0 0 2 |
This file contains 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/env python | |
lens=[] | |
for line in open('body.txt', 'r'): | |
l = line.rstrip("\n") | |
ll = l.split("\t") | |
lens.append(ll) | |
for lll in lens: | |
print "tag: %s" % lll[0][0:4] | |
for x in lll[1:]: | |
print str(float(x)), | |
print "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment