Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
# Created by Andrew Wooster on 2009-11-04.
# Copyright Planetary Scale LLC 2009.
# Released under the MIT License.
import sys
Takes iPhone app revenue data and combines sales from all apps into daily combined
Steps to use:
1. Export your data from AppViz with the "Revenue by Day" format.
2. ./ revenue.txt > revenue.csv
3. Do what you will.
def main(args):
filename = args[1]
contents = open(filename).read()
carryover = []
new_lines = []
for line in contents.splitlines():
if '$' not in line:
parts = line.split('\t')
parts[0] = parts[0].replace(' 00:00:00 +0000', '')
parts[2] = "Combined"
parts[3] = parts[3].replace('$', '')
if len(carryover) and parts[0] != carryover[0]:
carryover = parts
elif len(carryover):
carryover[3] = "%.2f" % (float(carryover[3]) + float(parts[3]))
carryover = parts
if len(carryover):
for line in new_lines:
print line
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment