Created
February 3, 2015 17:47
-
-
Save ckelner/962b9e52db11fc73cf68 to your computer and use it in GitHub Desktop.
dinky little py script to total up aws consolidated billing csvs. Needed because I have csvs w/ roughly 17mil rows in the ~7Gb file size range.
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
import csv | |
import sys | |
from decimal import Decimal | |
csv_file = open( sys.argv[1] ) | |
count = 0 | |
total_line_item_cost = Decimal(0) | |
for row in csv.reader( csv_file ): | |
count += 1 | |
# get record type (column 4) | |
rec_type = row[3] | |
if rec_type == "LineItem": | |
# get the 'UnBlendedCost' value (column 21) | |
unblended_cost = row[20] | |
total_line_item_cost += Decimal(unblended_cost.strip(' "')) | |
print "Rows processed: ", count | |
print "LineItem UnBlendedCost total: ", total_line_item_cost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment