Skip to content

Instantly share code, notes, and snippets.

@ivand58
Created March 28, 2021 10:36
Show Gist options
  • Save ivand58/64a1b296475fe3418514783928c4b4c0 to your computer and use it in GitHub Desktop.
Save ivand58/64a1b296475fe3418514783928c4b4c0 to your computer and use it in GitHub Desktop.
parser
#!/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