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:
- Create a list of product ids & sku ids from a previous play report as follows:
a. install csvkit - https://csvkit.readthedocs.io/en/749/
b. run the following command on a previous play report file that has all possible products and skus:
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
- Hack the source code of
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.
As of Feb/March 2017, Google Play Payment reports are missing the
Product idandSku idfields. 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:
a. install csvkit - https://csvkit.readthedocs.io/en/749/
b. run the following command on a previous play report file that has all possible products and skus:
app_earnings/google_play/parse.rbso it reads as follows: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.