Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- last_id = None
- last_value = 0
- for line in sys.stdin:
- (date, code, value) = line.split("\t")
- if (date, code) == last_id:
- last_value += value
- else:
- if last_id:
- print("{0},{1},{2}".format(last_id[0], last_id[1], last_value)
- last_id = (date, code)
- last_value = value
- if (date, code) == last_id:
- print("{0},{1},{2}".format(last_id[0], last_id[1], last_value)
Advertisement
Add Comment
Please, Sign In to add comment