Skip to content

Instantly share code, notes, and snippets.

@noexpect
Last active December 27, 2015 20:49
Show Gist options
  • Save noexpect/7386850 to your computer and use it in GitHub Desktop.
Save noexpect/7386850 to your computer and use it in GitHub Desktop.
tab区切りのテキストファイルの1列目をtag(_の前方のみを取得)として残りの列をfloatとして出力
0000_a 0 1 0 2
0001_b 0 0 3 0
0002_c 0 2 0 0
0003_d 1 0 0 2
#!/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