eggheadgames / app_earnings Goto Github PK
View Code? Open in Web Editor NEWProcess Google Play, Amazon Android app store csv report files into a text json summary by application and in-app purchase.
License: MIT License
Process Google Play, Amazon Android app store csv report files into a text json summary by application and in-app purchase.
License: MIT License
Currently it's possible to run:
app_earnings amazon EarningsReport-Mar-1-2014-Mar-31-2014.csv PaymentReport-Mar-1-2014-April-4-2014.csv
And get ouput that seems plausible. However, there are no payments in the PaymentReport that match dates in the EarningsReport. Please fail with a message saying that the dates don't match (and what dates they are) as this is a point of frequent confusion. E.g. an error like:
Incompatible data ranges. The file EarningsReport-Mar-1-2014-Mar-31-2014.csv summary has dates from 3/1/2014,3/31/2014. The PaymentReport-Mar-1-2014-April-4-2014.csv has dates from 2/1/2014,2/28/2014.
This should be easy to detect using the Summary section of the Payment report.
In my latest EarningsReport, I have a refund amount in GBP, like this:
Amazon.co.uk,3/1/2014,3/31/2014,"1234",-2,99.99,GBP,(1.67),GBP,0.00,GBP,98.32,GBP
The final amount in my report is off by the exactly the amount of 1.67 GBP when converted at the exchange rate given in the corresponding PaymentReport. It appears that the refunds column is being ignored completely in this scenario and hence the total doesn't match at the end. (Interestingly, perhaps, there are 2 refunds mentioned in the report details, but again, perhaps they aren't being calculated? Not sure ...)
As of Feb/March 2017, Google Play Payment reports are missing the Product id
and Sku id
fields. This is only for lines where the sales report code starts with "GPA".
The lack of these fields makes generating Google Play reports either fail outright, or not attribute all sales correctly.
I've worked around this as follows:
grep -v GPA PlayApps_xxxxxx.csv |
csvcut -c 7,8,10 |
sort -u |
grep -v "Product Title" |
sed -e '1s/^/Product Title,Product id,Sku id\'$'\n/' >map-names.csv
app_earnings/google_play/parse.rb
so it reads as follows:require 'csv'
module AppEarnings::GooglePlay
# Converts a csv file to a hash.
class Parser
attr_accessor :file_name
def initialize(file_name)
load_fixup
@file_name = file_name
end
def extract
@extracted_data = []
options = { headers: true, header_converters: :symbol }
CSV.foreach(@file_name, options) do |row|
hash_row = row.to_hash
hash_row = do_fixup(hash_row) if hash_row[:product_id].nil?
@extracted_data << hash_row
end
@extracted_data
end
def load_fixup
@fixup_table = []
options = { headers: true, header_converters: :symbol }
CSV.foreach("map-names.csv", options) do |row|
@fixup_table << row.to_hash
end
end
def do_fixup(row)
fix = @fixup_table.select {|f| f[:product_title] == row[:product_title]}[0]
row[:product_id] = fix[:product_id]
row[:sku_id] = fix[:sku_id]
row
end
end
end
That's it.
Hopefully Google stop producing files like this. Otherwise, I'll make an effort to clean this up and merge it into the code in a more elegant fashion.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.