Skip to content

Instantly share code, notes, and snippets.

@limed
Created September 19, 2019 00:46
Show Gist options
  • Save limed/9aa309c609b6710b5b061f96ae8868ce to your computer and use it in GitHub Desktop.
Save limed/9aa309c609b6710b5b061f96ae8868ce to your computer and use it in GitHub Desktop.
Parses info out of RI csv that cost explorer generates
#!/usr/bin/env python
import csv
from argparse import ArgumentParser
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-f", "--file", dest="csv_file",
required=True, help="CVS File to parse")
parser.add_argument("-d", "--debug", dest="debug", action='store_true',
default=False, help="Yep debug")
args = parser.parse_args()
with open (args.csv_file) as csvfile:
reader = csv.DictReader(csvfile)
print (f"RI Recommendations")
print (f"==================")
for row in reader:
if args.debug:
print (f"{row}\n")
else:
print (f"Location - {row['Location']}")
print (f"Instance Type - {row['Instance Type']}")
print (f"Payment Option - {row['Payment Option']}")
print (f"Upfront Cost - {row['Upfront Cost']}")
print (f"Recurring Monthly Cost - {row['Recurring Monthly Cost']}")
print (f"Estimated Monthly Savings - {row['Estimated Monthly Savings']}")
print (f"Break Even Months - {row['Break Even Months']}")
print (f"Recommended Instance Quantity Purchase - {row['Recommended Instance Quantity Purchase']}")
print (f"Recommended Normalized Unit Quantity Purchase - {row['Recommended Normalized Unit Quantity Purchase']}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment