Created
October 12, 2016 05:08
-
-
Save preetamtt/9751f3e091acc311e13838ab5f19ca57 to your computer and use it in GitHub Desktop.
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 | |
def main(argv): | |
inputPricingMap = argv[0] | |
rows = [] | |
with open(inputPricingMap) as csvfile: | |
reader = csv.DictReader(csvfile) | |
for row in reader: | |
rows.append(row) | |
with open(inputPricingMap + '.out', 'w') as csvfile: | |
fieldnames = ['request_category_id','question_id','answer_id','price','price_iq','price_cc','active','description'] | |
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | |
writer.writeheader() | |
for row in rows: | |
row['price_iq'] = int(round(int(row['price']) * 3.5)) | |
row['price_cc'] = int(round(int(row['price']) * 3.5)) | |
writer.writerow(row) | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: python create_price_iq_cc_cols_csv.py PricingMap.csv