Skip to content

Instantly share code, notes, and snippets.

@fkmhrk
Created February 21, 2015 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fkmhrk/df50e4b3bf5917af7fad to your computer and use it in GitHub Desktop.
Save fkmhrk/df50e4b3bf5917af7fad to your computer and use it in GitHub Desktop.
Google Playの収益レポート
import csv
import sys
#Description,Transaction Date,Transaction Time,Tax Type,Transaction Type,Refund Type,Product Title,Product id,Product Type,Sku Id,Hardware,Buyer Country,Buyer State,Buyer Postal Code,Buyer Currency,Amount (Buyer Currency),Currency Conversion Rate,Merchant Currency,Amount (Merchant Currency)
def debugPrint(row):
print "Description=%s" % (row[0])
print "Transaction Date=%s" % (row[1])
print "Transaction Time=%s" % (row[2])
print "Tax Type=%s" % (row[3])
print "Transaction Type=%s" % (row[4])
print "Refund Type=%s" % (row[5])
print "Product Title=%s" % (row[6])
print "Product id=%s" % (row[7])
print "Product Type=%s" % (row[8])
print "Sku Id=%s" % (row[9])
print "Hardware=%s" % (row[10])
print "Buyer Country=%s" % (row[11])
print "Buyer State=%s" % (row[12])
print "Buyer Postal Code=%s" % (row[13])
print "Buyer Currency=%s" % (row[14])
print "Amount (Buyer Currency)=%s" % (row[15])
print "Currency Conversion Rate=%s" % (row[16])
print "Merchant Currency=%s" % (row[17])
print "Amount (Merchant Currency)=%s" % (row[18])
print ""
r = csv.reader(open(sys.argv[1], 'rb'), delimiter=',', quotechar='"')
amount = 0
tax = 0
fee = 0
for row in r:
debugPrint(row)
transaction_type = row[4]
if transaction_type == 'Charge':
amount = amount + int(row[18])
if transaction_type == 'Tax':
tax = tax + int(row[18])
if transaction_type == 'Google fee':
fee = fee + int(row[18])
print "amount=%d" % (amount)
print "tax=%d" % (tax)
print "total=%d" % (amount + tax)
print ""
print "google fee=%d" % (fee)
print ""
print "income=%d" % (amount + tax + fee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment