Skip to content

Instantly share code, notes, and snippets.

@hyakuhei
Created February 23, 2016 15:08
Show Gist options
  • Save hyakuhei/803b9a47681f569b343d to your computer and use it in GitHub Desktop.
Save hyakuhei/803b9a47681f569b343d to your computer and use it in GitHub Desktop.
f = open("OpenStackVotesTXT.txt")
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
entries = []
entry = ""
for x in f.readlines():
s = x.strip()
if not is_number(s):
entries.append(entry)
entry = s
else:
entry += "|{0:.2f}".format(float(s))
for x in entries:
if len(x) > 2:
print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment