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[3] #chamber=sh.cell(10,1).value # chamber=sys.argv[2] # Run=sys.argv[3] location=sys.argv[2] Start=sys.argv[5] Stop=sys.argv[6] Date=str(Start[0:10]) comment=sys.argv[4] #Elog=sys.argv[7] #File=sys.argv[8] #Comment=sys.argv[9] Run = sh.cell(0,1).value root = generateXMLHeader("QC8_GEM_MASKED_STRIPS_HOT","GEM QC8 MASKED STRIPS HOT", "GEM HOT STRIPS QC8",str(Run),str(Start),str(Stop),str(comment),str(location),str(user)) dataSet = generateDataSetMultipleParts(root,comment,"1") for row in range(2,sh.nrows): ch_serial_number= sh.row_values(row)[0] gem_number= sh.row_values(row)[1] position= sh.row_values(row)[2] vfat= sh.row_values(row)[3] channel= sh.row_values(row)[4] strip= sh.row_values(row)[5] generateXMLDataQC8DeadStrips(dataSet,str(ch_serial_number),str(gem_number),str(position), str(vfat), str(channel),str(strip)) writeToFile(fileName,tostring(root))
def xml_from_csv(csv_file): lines = readFile(csv_file) for i in range(len(lines)): lines[i] = lines[i].split('\n')[0] Run = int(lines[0].split(',')[1]) Start = '2020-03-14 12:00:00' Stop = '2020-03-14 12:00:00' comment = '' location = '' user = '' root = generateXMLHeader("QC8_GEM_MASKED_STRIPS_HOT", "GEM QC8 MASKED STRIPS HOT", "GEM HOT STRIPS QC8", str(Run), str(Start), str(Stop), str(comment), str(location), str(user)) dataSet = generateDataSetMultipleParts(root, comment, "1") for line in range(2, len(lines)): ch_serial_number = str(lines[line].split(',')[0]) gem_number = str(lines[line].split(',')[1]) position = str(lines[line].split(',')[2]) vfat = int(lines[line].split(',')[3]) channel = int(lines[line].split(',')[4]) strip = int(lines[line].split(',')[5]) generateXMLDataQC8DeadStrips(dataSet, str(ch_serial_number), str(gem_number), str(position), str(vfat), str(channel), str(strip)) print(str(line - 1) + " / " + str(len(lines) - 2)) fileName = csv_file[:-4] + ".xml" writeToFile(fileName, tostring(root))
def xml_from_excel5(excel_file): wb = xlrd.open_workbook(excel_file) sh = wb.sheet_by_index(0) user = '' location = '' Start = '' Stop = '' comment = '' Run = sh.cell(0, 1).value root = generateXMLHeader("QC8_GEM_MASKED_STRIPS_DEAD", "GEM QC8 MASKED STRIPS DEAD", "GEM DEAD STRIPS QC8", str(Run), str(Start), str(Stop), str(comment), str(location), str(user)) dataSet = generateDataSetMultipleParts(root, comment, "1") for row in range(2, sh.nrows): ch_serial_number = sh.row_values(row)[0] gem_number = sh.row_values(row)[1] position = sh.row_values(row)[2] vfat = sh.row_values(row)[3] channel = sh.row_values(row)[4] strip = sh.row_values(row)[5] generateXMLDataQC8DeadStrips(dataSet, str(ch_serial_number), str(gem_number), str(position), str(vfat), str(channel), str(strip)) print(str(row - 1) + " / " + str(sh.nrows - 2)) writeToFile(fileName, tostring(root))