-
-
Save hyakuhei/803b9a47681f569b343d to your computer and use it in GitHub Desktop.
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
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