def __init__(self, pathconf=None, pathconfigexcelcopy=None): # call dict self.pathconfigexcelcopy = pathconfigexcelcopy dictconf = returndictrowforcsv(path=pathconf) self.__hm_startcopyrange = dictconf["hm_startcopyrange"] self.fname = dictconf["khns_namfile"] self.__startcopyrange = returnseplistintbbystr( self.__hm_startcopyrange) self.__hm_startpasterange = dictconf["hm_startpasterange"] self.__hm_hangmuc = dictconf["hm_hangmuc"] # copy another range botton self.__hm_startcopyrangebt = dictconf["hm_startcopyrange_bt"] self.__startcopyrangebt = returnseplistintbbystr( self.__hm_startcopyrangebt) self.__hm_startpasterangebt = dictconf["hm_startpasterange_bt"] self.pathlsn = refullpath(dirpath=getdirpath(pathconf), filename=dictconf["listsheetnamehm"]) self.copyhm = dictconf["copyhm"]
def habz60(self): """handling data azb-60 sheet""" col_msa = (self.dicrowconf["azb60_ms"]) startrowhm = int(self.dicrowconf["zab60_recor_l1"]) dongia = col2num(self.dicrowconf["azb60_dongia"]) dongia_abc = self.dicrowconf["azb60_dongia"] rangeketcauthep = (self.dicrowconf["azb60_rangeketcauthep"]) valueim = returnlist_from_listinstr( self.dicrowconf["zab60_valueim"].replace(":", ",")) m_row = self.wsheet.range( col_msa + str(self.wsheet.cells.last_cell.row)).end('up').row # return index row by value if len(valueim) != 0: lindexrow_im = lcellindexbyvalue(max_row=self.mrow, min_row=startrowhm, max_col=col_msa, min_col=col_msa, sheet=self.wsheet, lvalue=valueim) lvaluebyindecell_im = valuebyindexrowcell(lindexcell=lindexrow_im, col=dongia_abc, sheet=self.wsheet) # return range number rangese = returnseplistintbbystr(strint=rangeketcauthep) sumvalue = "=" + self.__returnsumvalue(iden="other", startrow60=startrowhm) rangecopyrefsamesheet(sheet=self.wsheet, formulasfirstcell=sumvalue, col_index=dongia, startrow=startrowhm, endrow=m_row) # rewwrite ket cau thep sumvalue = "=" + self.__returnsumvalue(iden="kct", startrow60=rangese[0]) rangecopyrefsamesheet(sheet=self.wsheet, formulasfirstcell=sumvalue, col_index=dongia, startrow=rangese[0], endrow=rangese[1]) if len(valueim) != 0: returnvaluekeyim(cola=dongia_abc, listvalue_im=lvaluebyindecell_im, sheet=self.wsheet, indexrow_im=lindexrow_im)
def __init__(self, pathconf=None): self.__pathconf = pathconf dictconf = returndictrowforcsv(path=pathconf) self.__hm_congtac = dictconf["hm_congtac"] self.__hm_bombt = dictconf["hm_bombt"] self.__hm_macmtc = dictconf["hm_macmtc"] self.__hm_materiasvattu = dictconf["hm_materiasvattu"] self.__hm_vlvk = dictconf["hm_vlvk"] self.__hm_VLTP = dictconf["hm_vltp"] self.__hm_MNCTP = dictconf["hm_mnctp"] self.__hm_VTKCT = dictconf["hm_vtkct"] self.__hm_NCKCT = dictconf["hm_nckct"] self.__hm_startpasterange = dictconf["hm_startpasterange"] sign_vk = dictconf["sign_vk"].replace(":", ",") self.sign_vk = returnlist_from_listinstr(sign_vk) sign_BT = dictconf["sign_bt"].replace(":", ",") self.sign_BT = returnlist_from_listinstr(sign_BT) self.__startpasterange = returnseplistintbbystr( self.__hm_startpasterange) self.pathlsn = refullpath(dirpath=getdirpath(pathconf), filename=dictconf["listsheetnamehm"]) fct = dictconf["fct"] try: self.lsheetname = convertcsvto1list(path=self.pathlsn) except: pass fname = dictconf["khns_namfile"] if fct.strip() == "all": self.wb = activeworkbook(namefile=fname, checknamefile=True) for sheet in self.lsheetname: print(sheet) self.wb.sheets[sheet].activate() self.__sheetdesactive = activesheet() self.m_row = self.__sheetdesactive.range( self.__hm_congtac + str(self.__sheetdesactive.cells.last_cell.row)).end( 'up').row self.__hdata() #self.copyrangfromconf() else: self.__sheetdesactive = activesheet() #self.copyrangfromconf() self.m_row = self.__sheetdesactive.range( self.__hm_congtac + str(self.__sheetdesactive.cells.last_cell.row)).end('up').row self.__hdata()
def __call__(self, *args, **kwargs): ws = kwargs["ws"] rmrange = kwargs["rmrange"] options = kwargs["option"] for rangea in rmrange: cols = lnumbercolumnbyrangstr(rstr=rangea) rows = returnseplistintbbystr(strint=rangea) a, b = startrow_endrow(ws=ws, rows=rows, cols=cols) for col in cols: for i in range(a, b + 1): instr = ws.range(i, col).value if (instr == "" or instr == None): pass else: for option in options: instr = self.f(instr=instr, option=option) ws.range(i, col).value = instr
def __call__(self, *args, **kwargs): self.__ws, rmrange = args for rangea in rmrange: self.__cols = lnumbercolumnbyrangstr(rstr=rangea) self.__rows = returnseplistintbbystr(strint=rangea) self.del_fun(**kwargs)
def __init__ (self, fpath = None, pathconf = None, pathconfigexcelcopy = None ): self.pathconf = pathconf self.pathconfigexcelcopy = pathconfigexcelcopy self.dicrowconf = returndictrowforcsv(path=pathconf) self.__fpath = fpath dirparhconf = parentdirectory(pathconf) self.__sheetnametor=self.dicrowconf["khns_sheetnamekhns"] self.__namefile=self.dicrowconf["khns_namfile"] self.__rangeg =self.dicrowconf["hm_rangege"] self.__rangeintct = returnseplistintbbystr(self.__rangeg) self.__rangestrct = returnliststr_from_str(self.__rangeg) self.__mvta = (self.dicrowconf["khns_mavatu"]) self.__mvt = col2num (self.__mvta) self.__khns_ndcva = (self.dicrowconf["khns_noidungcongviec"]) self.__khns_ndcv = col2num (self.__khns_ndcva) self.__khns_dvta = (self.dicrowconf["khns_dvt"]) self.__khns_dvt = col2num (self.__khns_dvta) self.__khns_muchaophi = (self.dicrowconf["khns_muchaophi"]) self.__khns_muchaophi_int = col2num(self.__khns_muchaophi) self.__hm_mvt = int(self.dicrowconf["hm_mvt"]) self.__hm_ndcv = int(self.dicrowconf["hm_noidungcongviec"]) self.__hm_dvt = int(self.dicrowconf["hm_dvt"]) self.__hm_dgth_str = (self.dicrowconf["hm_dgth"]) self.__hm_dgth = col2num(self.__hm_dgth_str) self.__hm_ttnt_str = (self.dicrowconf["hm_ttnt"]) self.__hm_ttnt = col2num(self.__hm_ttnt_str) self.__hm_startrowvalue = int(self.dicrowconf["hm_startrowvalue"]) self.__hm_vta = self.dicrowconf["hm_vt"] self.__hm_nca = self.dicrowconf["hm_nc"] self.__hm_mtca = self.dicrowconf["hm_mtc"] self.__hm_tha = self.dicrowconf["hm_th"] self.__hm_ct = self.dicrowconf["hm_ct"] self.__hm_ct_int = col2num(self.__hm_ct) self.__hm_vt =col2num (self.dicrowconf["hm_vt"]) self.__hm_nc =col2num (self.dicrowconf["hm_nc"]) self.__hm_mtc =col2num (self.dicrowconf["hm_mtc"]) self.__hm_th =col2num (self.dicrowconf["hm_th"]) self.__valuenotnone =self.dicrowconf["valuenotnone"] valueall =self.dicrowconf["valueall"] self.__dictvalue =self.dicrowconf["dictvalue"] # csv for dict self.pathtovalue = refullpath(dirparhconf,self.__dictvalue) # csv for value self.valuenotnone = refullpath(dirparhconf,self.__valuenotnone) # path all value self.pathvalueall = refullpath(dirparhconf,valueall) self.__khns_rangenumbermct_ptvt =self.dicrowconf["khns_rangenumbermct_ptvt"] # hangmuccongtac self.__hm_startpasterange = self.dicrowconf["hm_startpasterange"] self.__startpasterange = returnseplistintbbystr(self.__hm_startpasterange) self.__hm_congtac = self.dicrowconf["hm_congtac"] # add new##########################################################################33 self.__khns_macongtac = self.dicrowconf["khns_macongtac"] self.__khns_noidungcongviec = self.dicrowconf["khns_noidungcongviec"] self.__khns_vattu = self.dicrowconf["khns_vattu"] self.__khns_nhancong = self.dicrowconf["khns_nhancong"] self.__khns_maytc = self.dicrowconf["khns_maytc"] self.__hm_th_formulas = self.dicrowconf["hm_th_formulas"] self.__khns_startrow = int(self.dicrowconf["khns_startrow"]) # return list ma cong tac not node in cell value of ptvl by csv self.getvaluelist = convertcsvtolist(path=self.valuenotnone) # return all value from csv self.getallvalue = convertcsvtolist(path=self.pathvalueall) self.pathlsn = refullpath(dirpath=getdirpath(pathconf), filename=self.dicrowconf["listsheetnamehm"]) try: self.lsheetname = convertcsvto1list(path=self.pathlsn) except: pass self.__returnothervalue() self.__returnlistcongtac()