Last active
August 29, 2015 13:56
-
-
Save AndreaCatalucci/9230615 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
#! /usr/bin/env python | |
import sys | |
for line in sys.stdin: | |
data = line.strip().split("\t") | |
if len(data) != 6: | |
continue | |
date, time, store, item, cost, payment = data | |
print "{0}\t{1}".format(store, cost) |
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 | |
for line in sys.stdin: | |
data = line.strip().split("\t") | |
if len(data) != 6: | |
continue | |
date, time, store, item, cost, payment = data | |
print "{0}\t{1}".format(store, cost) |
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 | |
sales_total = 0 | |
old_key = None | |
for line in sys.stdin: | |
data = line.strip().split("\t") | |
if len(data) != 2: | |
continue | |
key, sales = data | |
if (old_key and key != old_key): | |
print "{0}\t{1}".format(old_key, sales_total) | |
sales_total = 0 | |
old_key = key | |
sales_total += float(sales) | |
print "{0}\t{1}".format(old_key, sales_total) |
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 | |
max_cost = 0 | |
old_key = None | |
for line in sys.stdin: | |
data = line.strip().split("\t") | |
if len(data) != 2: | |
continue | |
store, cost = data | |
if (old_key and key != old_key): | |
print "{0}\t{1}".format(old_key, sales_total) | |
max_cost = 0 | |
old_key = key | |
max_cost = max(cost, max_cost) | |
print "{0}\t{1}".format(old_key, max_cost) |
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 | |
sales_total = 0 | |
sales_num = 0 | |
old_key = None | |
for line in sys.stdin: | |
data = line.strip().split("\t") | |
if len(data) != 2: | |
continue | |
key, sales = data | |
if (old_key and key != old_key): | |
print "{0}\t{1}".format(old_key, sales_total) | |
sales_total = 0 | |
old_key = key | |
sales_total += float(sales) | |
sales_num += 1 | |
print "{0}\t{1}\t{1}".format(old_key, sales_total, sales_num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment