aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse_report.rb29
1 files changed, 21 insertions, 8 deletions
diff --git a/parse_report.rb b/parse_report.rb
index 840708e..aac426b 100644
--- a/parse_report.rb
+++ b/parse_report.rb
@@ -12,15 +12,28 @@ sales_by_date = {}
rows = CSV.foreach(ARGV[0], csv_opts)
rows.each do |row|
- d = Date.parse(row["Date"])
- if sales_by_date[d]
- sales_by_date[d][:count] += row["quantity"]
- sales_by_date[d][:total] += row["revenue EUR"]
- else
- sales_by_date[d] = {:count => row["quantity"], :total => row["revenue EUR"]}
+ if row.count > 0
+ d = Date.parse(row["Date"])
+ if sales_by_date[d]
+ sales_by_date[d][:count] += row["quantity"]
+ sales_by_date[d][:total] += row["revenue EUR"]
+ else
+ sales_by_date[d] = {:count => row["quantity"], :total => row["revenue EUR"]}
+ end
end
end
-sales_by_date.each do |row|
- p row
+puts "Date: Streams: Revenue:"
+puts "------------------------------------------"
+
+total_rev = 0
+total_streams = 0
+
+sales_by_date.each do |key, row|
+ puts "#{key.iso8601}: #{row[:count].to_s.rjust(7)} #{row[:total].round(5).to_s.rjust(10)} EUR"
+ total_rev += row[:total]
+ total_streams += row[:count]
end
+
+puts "------------------------------------------"
+puts "Total: #{total_streams.to_s.rjust(7)} #{total_rev.round(5).to_s.rjust(10)} EUR"