Created
August 12, 2020 13:22
-
-
Save oisin/9172bc266f4bd6badee8aed3d95dfb61 to your computer and use it in GitHub Desktop.
Some ruby for breaking up AWS bills in XLSX form.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'creek' | |
fname = ARGV[0] | |
abort("Please supply file name") if fname.nil? | |
book = Creek::Book.new 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") | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment