def xml_from_excel3(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) tags = [n.replace(" ", "").lower() for n in sh.row_values(0)] Start=str(ObtainDate("Test Start Time(with Date like 2017-01-16):","%Y-%m-%d %H:%M:%S")) #print "Test Start At:" +str(Start) Stop=str(ObtainDate("Test End Time:","%Y-%m-%d %H:%M:%S")) #print "Test End At:" + str(Stop) chamber=sh.cell(2,7).value #print "Chamber is selected:" +str(chamber) #Date=sh.cell(0,7).value Date=str(Start[0:10]) ##print Date #location=raw_input("Enter Location:") location = "PLACEHOLDER_LOCATION" #print "Test Done At:"+str(location) user=sh.cell(1,7).value #print "Test Done By:" +str(user) #comment=raw_input("Make a Comment:") comment = "PLACHOLDER_COMMENT" #print "Here what you Comment:" +str(comment) Run=db.engine.execute("select nvl(max(run.RUN_NUMBER), 0) + 1 from cms_gem_core_cond.cond_data_sets dat join cms_gem_core_cond.kinds_of_conditions koc on dat.KIND_OF_CONDITION_ID = koc.KIND_OF_CONDITION_ID join CMS_GEM_CORE_CONSTRUCT.PARTS par on par.PART_ID = dat.PART_ID join CMS_GEM_CORE_COND.COND_RUNS run on dat.COND_RUN_ID = run.COND_RUN_ID where koc.IS_RECORD_DELETED = 'F' and par.IS_RECORD_DELETED = 'F' and koc.name = '' and par.SERIAL_NUMBER = '"+chamber+"'") Run = [ t for t, in Run ] #print "Number of Time Test Perform:"+str(Run[0]) root = generateXMLHeader("QC3_GAS_LEAK_CALIB","GEM Chamber QC3 Gas Leak Calib Data","CERN Station A GEM Chamber QC3 Gas Leak Calibration",str(Run[0]),Start,Stop,comment,location,user) dataSet = generateDataSet(root,"GEM Chamber QC3 Gas Leak Calib Data","1","GEM Chamber",chamber) for row in range(1,sh.nrows): seconds= sh.row_values(row)[1] pre= sh.row_values(row)[2] temp =sh.row_values(row)[3] ambp= sh.row_values(row)[4] #times=datetime.strftime(sh.row_values(row)[0], '%H:%M:%S') times = xlrd.xldate_as_tuple(sh.row_values(row)[0], wb.datemode) ##print times[3:] times=str(times).replace(",",":") times = str(times).replace(")","") times = str(times).replace("("," ") ##print times generateXMLData3(dataSet,Date +str(times[9:]),str(seconds),str(pre), str(ambp), str(temp)) writeToFile(fileName, tostring(root)) test_date=sh.cell(0,7).value avgtemp=sh.cell(32,7).value stdtemp=sh.cell(32,8).value avgpre=sh.cell(33,7).value stdpre=sh.cell(33,8).value initpre = sh.cell(34,7).value finalpre = sh.cell(35,7).value duration = sh.cell(36,7).value leakrate = sh.cell(37,7).value expofitp0=sh.cell(38,7).value expofitp1=sh.cell(39,7).value expofitR2=sh.cell(40,7).value #elog=raw_input("Please Enter the ELOG LINK:") #File=raw_input("Please Enter the File Name:") #Comments=raw_input("Make a Summary Comment:") elog="PLACEHOLDER_ELOG" File="PLACEHOLDER_FILE" Comments="PLACHOLDER_COMMENTS" root = generateXMLHeader("QC3_GAS_LEAK_CalIB_SUMMARY","GEM Chamber QC3 Gas Leak Calib Summary ","CERN Station A GEM Chamber QC3 Gas Leak Calib Summary",str(Run[0]),Start,Stop,comment, location,user) dataSet = generateDataSet(root,"GEM Chamber QC3 Gas Leak Calib Summary","1","GEM Chamber",chamber) generateXMLData3a(dataSet, str(test_date) ,str(avgtemp),str(stdtemp),str(avgpre),str(stdpre),str(initpre),str(finalpre),str(duration),str(leakrate),str(expofitp0),str(expofitp1),str(expofitR2),str(elog),str(File),str(Comments)) writeToFile1(testfile, tostring(root))
duration = sh.cell(36,7).value leakrate = sh.cell(37,7).value expofitp0=sh.cell(38,7).value expofitp1=sh.cell(39,7).value expofitR2=sh.cell(40,7).value elog=raw_input("Please Enter the ELOG LINK:") File=raw_input("Please Enter the File Name:") Comments=raw_input("Make a summary Comment:") root = generateXMLHeader("QC3_GAS_LEAK_DATA_SUMMARY","GEM Chamber QC3 Gas Leak Data Summary ","CERN Station A GEM Chamber QC3 Gas Leak Data Summary",Run,Start,Stop,comment, location,user) dataSet = generateDataSet(root,"GEM Chamber QC3 Gas Leak Data Summary","1","GEM Chamber",chamber) generateXMLData3a(dataSet, str(test_date) ,str(avgtemp),str(stdtemp),str(avgpre),str(stdpre),str(initpre),str(finalpre),str(duration),str(leakrate),str(expofitp0),str(expofitp1),str(expofitR2),str(elog),str(File),str(Comments)) writeToFile1(datafile, tostring(root)) if select==3: root = generateXMLHeader("QC3_GAS_FULL_SUMMARY","GEM Chamber QC3 Gas Full Summary","CERN Station A GEM Chamber QC3 Gas Full Summary",Run,Start,Stop,comment,location,user) dataSet = generateDataSet(root,"GEM Chamber QC3 Gas Full Summary","1","GEM Chamber",chamber) #QC4 if ch==4: def xml_from_excel4(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) req = sh.cell(1,16).value pre = sh.cell(5,16).value amp = sh.cell(8,16).value coa = sh.cell(9,16).value fine = sh.cell(10,16).value itime = sh.cell(12,16).value dtime = sh.cell(13,16).value disc = sh.cell(16,16).value thrs = sh.cell(17,16).value
def xml_from_excel4(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) req = sh.cell(1, 16).value pre = sh.cell(5, 16).value amp = sh.cell(8, 16).value coa = sh.cell(9, 16).value fine = sh.cell(10, 16).value itime = sh.cell(12, 16).value dtime = sh.cell(13, 16).value disc = sh.cell(16, 16).value thrs = sh.cell(17, 16).value scal = sh.cell(20, 16).value daq = sh.cell(21, 16).value Start = sys.argv[7] Stop = sys.argv[8] chamber = sys.argv[2] Date = str(Start[0:10]) location = sys.argv[4] #user=sh.cell(1,7).value user = sys.argv[5] comment = sys.argv[6] Comment = sys.argv[11] Run = sys.argv[3] root = generateXMLHeader("QC1_HVDRIFT_CONFIG", "GEM Drift PCB QC1 HV Drift Configuration", str(location) + " GEM QC1 Drfit Config HV Test", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) generateXMLData4a(dataSet, str(req), str(pre), str(amp), str(coa), str(fine), str(itime), str(dtime), str(disc), str(thrs), str(scal), str(daq)) writeToFile(fileName, tostring(root)) root = generateXMLHeader("QC1_HVDRIFT_DATA", "GEM Drift PCB QC1 HV Drift Data", str(location) + " GEM QC1 Drift Data HV Test", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) for row in range(3, sh.nrows): if sh.row_values(row)[0] == '': break vset = sh.row_values(row)[0] vmon = sh.row_values(row)[1] iset = sh.row_values(row)[2] imon = sh.row_values(row)[3] rcal = sh.row_values(row)[4] rnorm = sh.row_values(row)[5] count = sh.row_values(row)[6] rate = sh.row_values(row)[7] error = sh.row_values(row)[8] generateXMLData4(dataSet, str(vset), str(vmon), str(iset), str(imon), str(rcal), str(rnorm), str(count), str(rate), str(error)) writeToFile(datafile, tostring(root)) v_max = sh.cell(25, 16).value test_date = Start v_drift = sh.cell(26, 16).value i_max = sh.cell(27, 16).value r_euq = sh.cell(28, 16).value r_err = sh.cell(29, 16).value r_diff = sh.cell(30, 16).value spr_signal = sh.cell(31, 16).value spr_error = sh.cell(32, 16).value Filename = sys.argv[10] Elog = sys.argv[9] #Comment=sys.argv[11] root = generateXMLHeader("QC1_HVDRIFT_SUMRY", "GEM Drift PCB QC1 HV Drift Summary", str(location) + " GEM QC1 HV Test Summary", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) generateXMLData4s(dataSet, test_date, str(v_max), str(i_max), str(v_drift), str(r_euq), str(r_err), str(r_diff), str(spr_signal), str(Filename), str(Elog), str(Comment)) writeToFile(testfile, tostring(root))
def xml_from_excel5(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) #user = sh.cell(0,1).value user = sys.argv[5] #chamber=sh.cell(10,1).value chamber = sys.argv[2] Run = sys.argv[3] location = sys.argv[4] Start = sys.argv[7] Stop = sys.argv[8] Date = str(Start[0:10]) comment = sys.argv[6] Elog = sys.argv[9] File = sys.argv[10] Comment = sys.argv[11] user_name = sh.cell(1, 1).value amp = sh.cell(4, 1).value coa = sh.cell(5, 1).value fine = sh.cell(6, 1).value itime = sh.cell(8, 1).value dtime = sh.cell(7, 1).value disc = sh.cell(27, 1).value thrs = sh.cell(28, 1).value walk = sh.cell(29, 1).value width = sh.cell(30, 1).value scal = sh.cell(40, 1).value daq = sh.cell(41, 1).value pico = sh.cell(33, 1).value #tred = sh.cell(34,1).value #tblack = sh.cell(35,1).value #tgreen = sh.cell(36,1).value source = sh.cell(44, 1).value hvlt = sh.cell(45, 1).value current = sh.cell(46, 1).value activity_bq = sh.cell(47, 1).value filter_status = sh.cell(48, 1).value collimator_status = sh.cell(49, 1).value nbpri = sh.cell(23, 5).value eta = sh.cell(12, 1).value gas = sh.cell(13, 1).value gfac = sh.cell(14, 1).value flow = sh.cell(15, 1).value req = sh.cell(16, 1).value divi = sh.cell(17, 1).value avtemp = sh.cell(47, 5).value error_temp = sh.cell(48, 5).value amb = sh.cell(49, 5).value error_amb = sh.cell(50, 5).value expo1 = sh.cell(51, 5).value expo2 = sh.cell(52, 5).value p5p0 = sh.cell(47, 8).value p5t0 = sh.cell(48, 8).value root = generateXMLHeader("QC5_EFF_GAIN_CONFIG", "GEM Chamber QC5 Effective Gain Config", str(location) + " GEM Chamber QC5 Effective Gain", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) generateXMLData5a(dataSet, str(user_name), str(amp), str(coa), str(fine), str(itime), str(dtime), str(disc), str(thrs), str(walk), str(width), str(scal), str(daq), str(pico), str(source), str(hvlt), str(current), str(nbpri), str(eta), str(gas), str(gfac), str(flow), str(req), str(divi), str(activity_bq), str(filter_status), str(collimator_status)) writeToFile(fileName, tostring(root)) root = generateXMLHeader("QC5_EFF_GAIN_DATA", "GEM Chamber QC5 Effective Gain Data", str(location) + " GEM Chamber QC5 Effective Gain", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) #for row in range(5,21): for row in range(29, 45): #test_time= sh.row_values(row-24)[7] test_time = xlrd.xldate_as_tuple( sh.row_values(row - 24)[7], wb.datemode) test_time = str(test_time).replace(",", ":") test_time = str(test_time).replace(")", "") test_time = str(test_time).replace("(", " ") pressure = sh.row_values(row - 24)[8] temp = sh.row_values(row - 24)[9] vmon = sh.row_values(row)[5] imon = sh.row_values(row)[4] vdrift = sh.row_values(row)[6] rate = sh.row_values(row)[7] rate_error = sh.row_values(row)[8] current = sh.row_values(row)[9] current_error = sh.row_values(row)[10] gain = sh.row_values(row)[11] gain_error = sh.row_values(row)[12] generateXMLData5(dataSet, Date + str(test_time[9:]), str(temp), str(pressure), str(imon), str(vmon), str(vdrift), str(rate), str(rate_error), str(current), str(current_error), str(gain), str(gain_error)) writeToFile(datafile, tostring(root)) root = generateXMLHeader("QC5_EFF_GAIN_SUMRY", "GEM Chamber QC5 Effective Gain Summary", str(location) + " GEM Chamber QC5 Effective Gain", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comment, "1", "GEM Chamber", chamber) generateXMLData5s(dataSet, str(Start), str(avtemp), str(amb), str(expo1), str(expo2), str(File), str(Elog), str(Comment), str(error_temp), str(error_amb), str(p5p0), str(p5t0)) writeToFile(testfile, tostring(root))
def xml_from_excel3(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) #tags = [n.replace(" ", "").lower() for n in sh.row_values(0)] #Start=sys.argv[6]+ " " + sys.argv[7] #Stop=sys.argv[8]+ " " + sys.argv[9] Start = sys.argv[6] Stop = sys.argv[7] #chamber=sh.cell(2,7).value chamber = sys.argv[11] Date = str(Start[0:10]) location = sys.argv[3] user = sys.argv[4] comment = sys.argv[5] Comments = sys.argv[10] Run = sys.argv[2] root = generateXMLHeader("QC3_GAS_LEAK_CALIB", "GEM Chamber QC3 Gas Leak Calib Data", str(location) + " GEM QC3 Gas Calib Data", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comments, "1", "GEM Chamber", chamber) for row in range(1, sh.nrows): seconds = sh.row_values(row)[1] pre = sh.row_values(row)[2] temp = sh.row_values(row)[3] ambp = sh.row_values(row)[4] increment_hr = sh.row_values(row)[5] temp_k = sh.row_values(row)[6] times = xlrd.xldate_as_tuple(sh.row_values(row)[0], wb.datemode) times = str(times).replace(",", ":") times = str(times).replace(")", "") times = str(times).replace("(", " ") #generateXMLData3(dataSet,Date +str(times[9:]),str(seconds),str(pre), str(ambp), str(temp)) generateXMLData3(dataSet, str(Date), str(seconds), str(pre), str(ambp), str(temp), str(increment_hr), str(temp_k)) writeToFile(fileName, tostring(root)) #test_date=sh.cell(0,7).value test_date = Start avgtemp = sh.cell(32, 10).value stdtemp = sh.cell(32, 11).value avgpre = sh.cell(33, 10).value stdpre = sh.cell(33, 11).value initpre = sh.cell(34, 10).value finalpre = sh.cell(35, 10).value duration = sh.cell(36, 10).value leakrate = sh.cell(37, 10).value expofitp0 = sh.cell(38, 10).value expofitp1 = sh.cell(39, 10).value time_constant = sh.cell(40, 10).value elog = sys.argv[8] File = sys.argv[9] #Comments=sys.argv[10] root = generateXMLHeader("QC3_GAS_LEAK_CALIB_SUMRY", "GEM Chamber QC3 Gas Leak Calib Summary", str(location) + " GEM QC3 Gas Calib Data", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, Comments, "1", "GEM Chamber", chamber) generateXMLData3a(dataSet, str(test_date), str(avgtemp), str(stdtemp), str(avgpre), str(stdpre), str(initpre), str(finalpre), str(duration), str(leakrate), str(expofitp0), str(expofitp1), str(elog), str(File), str(Comments), str(time_constant)) writeToFile1(testfile, tostring(root))
def xml_from_excel5(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) user = sh.cell(0, 1).value chamber = sh.cell(10, 1).value pre = raw_input("Please Enter Preamplifier Name:") amp = sh.cell(3, 1).value coa = sh.cell(4, 1).value fine = sh.cell(5, 1).value itime = sh.cell(6, 1).value dtime = sh.cell(7, 1).value disc = sh.cell(26, 1).value thrs = sh.cell(27, 1).value walk = sh.cell(28, 1).value width = sh.cell(29, 1).value scal = sh.cell(39, 1).value daq = sh.cell(40, 1).value pico = sh.cell(32, 1).value tred = sh.cell(33, 1).value tblack = sh.cell(34, 1).value tgreen = sh.cell(35, 1).value source = sh.cell(43, 1).value hvlt = sh.cell(44, 1).value current = sh.cell(45, 1).value nbpri = "346" eta = sh.cell(11, 1).value gas = sh.cell(12, 1).value gfac = sh.cell(13, 1).value flow = sh.cell(14, 1).value req = sh.cell(15, 1).value divi = sh.cell(16, 1).value root = generateXMLHeader( "QC5_GAIN_STBLTY_CONFIG", "GEM Chamber QC5 Gain Stability", "CERN Station A GEM Chamber QC5 Gain Stability", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, "GEM Chamber QC5 Gain Stability Config", "1", "GEM Chamber", chamber) generateXMLData5a(dataSet, str(user), pre, str(amp), str(coa), str(fine), str(itime), str(dtime), str(disc), str(thrs), str(walk), str(width), str(scal), str(daq), str(pico), str(tred), str(tblack), str(tgreen), str(source), str(hvlt), str(current), str(nbpri), str(eta), str(gas), str(gfac), str(flow), str(req), str(divi)) writeToFile(fileName, tostring(root)) root = generateXMLHeader( "QC5_GAIN_STBLTY_DATA", "GEM Chamber QC5 Gain Stability Data", "CERN Station A GEM Chamber QC5 Gain Stability", Run, Start, Stop, comment, location, user) dataSet = generateDataSet(root, "GEM Chamber QC5 Gain Stability Data", "1", "GEM Chamber", chamber) for row in range(6, sh.nrows): if row == 33: break test_time = str(Start[0:10]) humidity = raw_input("Please write Humidity Value:") vmon = sh.row_values(row)[5] imon = sh.row_values(row)[6] time = sh.row_values(row)[21] pressure = sh.row_values(row)[22] temp = sh.row_values(row)[23] s_count = sh.row_values(row)[24] s_error = sh.row_values(row)[25] off_count = sh.row_values(row)[26] off_error = sh.row_values(row)[27] s_current = sh.row_values(row)[28] s_current_error = sh.row_values(row)[29] off_current = sh.row_values(row)[30] off_current_error = sh.row_values(row)[31] generateXMLData5(dataSet, str(test_time), str(temp), str(pressure), str(humidity), str(imon), str(vmon), str(s_count), str(s_error), str(off_count), str(off_error), str(s_current), str(s_current_error), str(off_current)) writeToFile(datafile, tostring(root))