Skip to content

Instantly share code, notes, and snippets.

@preetamtt
Created October 12, 2016 05:08
Show Gist options
  • Save preetamtt/9751f3e091acc311e13838ab5f19ca57 to your computer and use it in GitHub Desktop.
Save preetamtt/9751f3e091acc311e13838ab5f19ca57 to your computer and use it in GitHub Desktop.
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:])
@preetamtt
Copy link
Author

Usage: python create_price_iq_cc_cols_csv.py PricingMap.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment