Created
March 28, 2021 10:36
-
-
Save ivand58/64a1b296475fe3418514783928c4b4c0 to your computer and use it in GitHub Desktop.
parser
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 | |
import sys | |
k = 0 | |
try: | |
buff = '' | |
while True: | |
buff += sys.stdin.read(1) | |
if buff.endswith('\n'): | |
try: | |
x, y = buff.expandtabs().strip().split() | |
except ValueError: | |
break | |
if '$' == x[0]: | |
a = int(x[1:],16) | |
else: | |
a = int(x) | |
b = float(y) | |
print '{:03d}\t{}'.format(a, b) | |
buff = '' | |
k = k + 1 | |
except KeyboardInterrupt: | |
sys.stdout.flush() | |
pass | |
print >> sys.stderr, "Number of lines:", k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment