import csv output = file('trailers.csv', "w") wr = csv.writer(output,delimiter=',',lineterminator='\n') Data_Write=['CY','MY','Van_type','Haul_Type','Option','% in Compliance','Aerodynamic','LRR','Total'] wr.writerow(Data_Write) van_type=["dry","reefer"] road_type=["highway"] haul_type=["long","local","short"] Option1_comp_perc=[0.05,0.15,0.30,0.50,0.75,1]# [2010,2011,2012,2013,2014,2015,2016] Option2_comp_perc=[0.0,0.2,0.40,0.60,0.80,1]# [2010,2011,2012,2013,2014,2015,2016] Small_comp_perc=[0.0,0.0,0.0,0.25,0.50,0.75,1]# [2010,2011,2012,2013,2014,2015,2016,2017] for CY in range(2010,2052): for MY in range(1965,CY+1): for van in van_type: for road in road_type: for haul in haul_type: if (CY>=2011) and (MY<=2010) and (haul=="long"): option_type=["option 0","option 1","option 2","small"] else: option_type=["no option"] for option in option_type: AERO=0 LRR=0 if (CY>=2010) and (MY>=2011) and (haul=="long"): if van=="dry": if road=="highway": AERO=0.05 LRR=0.015 else: AERO=0 LRR=0.015 if van=="reefer": if road=="highway": AERO=0.04 LRR=0.015 else: AERO=0 LRR=0.015 if (CY>=2017) and (MY<=2010) and (haul=="long"): if van=="dry": LRR=0.015 if van=="reefer": if (MY==2003 or MY==2004) and (CY>=2018): LRR=0.015 if (MY==2005 or MY==2006) and (CY>=2019): LRR=0.015 if (MY>=2007 or MY<=2009) and (CY>=2020): LRR=0.015 if (MY<2003 or MY>2009): LRR=0.015 if (CY>=2011) and (MY<=2010) and (haul=="long") and (van=="dry"): if road=="highway": AERO=0.05 else: AERO=0 if (CY>=2011) and (MY<=2010) and (haul=="long") and (van=="reefer"): if (MY==2003 or MY==2004) and (CY>=2018): if road=="highway": AERO=0.04 else: AERO=0 if (MY==2005 or MY==2006) and (CY>=2019): if road=="highway": AERO=0.04 else: AERO=0 if (MY>=2007 or MY<=2009) and (CY>=2020): if road=="highway": AERO=0.04 else: AERO=0 if (MY<2003 or MY>2009): if road=="highway": AERO=0.04 else: AERO=0 if (option=="no option"): compliance_perc=1 if (option=="option 0"): if CY<2013: compliance_perc=0 else: compliance_perc=1 if (option=="option 1"): if CY<2017: compliance_perc=Option1_comp_perc[CY-2011] else: compliance_perc=1 if (option=="option 2"): if CY<2017: compliance_perc=Option2_comp_perc[CY-2011] else: compliance_perc=1 if (option=="small"): if CY<2018: compliance_perc=Small_comp_perc[CY-2011] else: compliance_perc=1 AERO=AERO*compliance_perc; if (haul=="local"): AERO=0 if (CY>=2017) and (MY<=2010): if van=="dry": LRR=0.015 if van=="reefer": if (MY==2003 or MY==2004) and (CY>=2018): LRR=0.015 if (MY==2005 or MY==2006) and (CY>=2019): LRR=0.015 if (MY>=2007 or MY<=2009) and (CY>=2020): LRR=0.015 if (MY<2003 or MY>2009): LRR=0.015 if (haul=="short"): AERO=0 LRR=0.0 if (CY<=2050): Data=[CY,MY,van,haul,option,compliance_perc,AERO,LRR,AERO+LRR] wr.writerow(Data) if (CY>2010) and (CY==MY): Data=[CY-1,MY,van,haul,option,compliance_perc,AERO,LRR,AERO+LRR] wr.writerow(Data) output.close()