Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2020 13:22
What would you like to do?
Some ruby for breaking up AWS bills in XLSX form.
#!/usr/bin/env ruby
require 'creek'
fname = ARGV[0]
abort("Please supply file name") if fname.nil?
book = fname, with_headers: true
allocations = book.sheets[0]
rowid = 0
allocations.simple_rows.each { |r|
rowid += 1
desc = r['ItemDescription'] || next
# puts r
if (r['ItemDescription'].include?('reserved instance'))
match = /([a-z][0-9][a-z]*\.\w+) /.match(r['ItemDescription'])
puts("%s,%s" % [r['AvailabilityZone'] || "no az", match[1] || match[0]], r['user:Service'] || "no service", r['user:Role'] || "no role", r['user:Name'] || "no name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment