def highlight_columns(sheetname): dif_items = get_dif_columns(sheetname) excel = Excel(settings.TGT_FILE_PATH) wb = excel.get_wb() ws = excel.get_sheet(sheetname) max_row = excel.get_max_row(sheetname) col_hdr = [] for dif_col in dif_items: col_hdr_item = excel.convert_col2header(sheetname=sheetname, column_name=dif_col) col_hdr.append(col_hdr_item) #print(col_hdr) # for row_nbr in range(1,max_row-490): # for hdr in col_hdr: # cell_item = hdr+str(row_nbr) # print(cell_item) # cell_item.fill = openpyxl.styles.fills.Color. # ws[cell_item].fill = colors.RED # # wb.save('new_compare_result.xlsx') for item in get_dif_columns(sheetname): cells = excel.get_column(sheetname, column_name=item) print(cells) for cell in cells: cell.fill = PatternFill(patternType='solid', fgColor='00FF0000') wb.save('new_compare_result.xlsx')
def setBgColor(sheetname): _getSetList = get_diff_rowdata(sheetname) _filepath = settings.TGT_FILE_PATH _excel = Excel(_filepath) _wb = _excel.get_wb() _ws = _excel.get_sheet(sheetname) for curitem in _ws.iter_rows(): if curitem[0].row in _getSetList: for cell in curitem: cell.fill = PatternFill(fgColor='FF0000', fill_type='solid') _wb.save(settings.END_FILE_PATH)
def get_data_message(path,sheetname,idx=None): #initial index into list _headername = [] #store message data _alldata = [] _excel = Excel(path) if idx is None: _mactch_column_name = compareData.get_match_columns(sheetname) for columnname in _mactch_column_name: _curcells = _excel.convert_col2header(sheetname,columnname) _headername.append(_curcells) else: _indexCols = idx.split(',') _mactch_column_name = compareData.get_match_columns(sheetname, _indexCols) for columnname in _indexCols: _curcells = _excel.convert_col2header(sheetname, columnname) _headername.append(_curcells) _cursheet = _excel.get_sheet(sheetname) for _row in range(2, _cursheet.max_row+1): _rowdata = [] for _column in _headername: _cellname = "{}{}".format(_column, _row) #get current cell line number and line column _cellvalue = _cursheet[_cellname].value _cellvalue = str(_cellvalue).upper() _rowdata.append(_cellvalue.strip()) #upper all values _alldata.append(_rowdata) for _item in _alldata[::-1]: if _item in _alldata: _getcount = _alldata.count(_item) _item.append(_getcount) return _alldata
if con.acquire(): if len(queue) < 0: con.wait() else: elem = queue.pop() print("Consumer a elem {}. Now size is {}".format( elem, len(queue))) time.sleep(random.random()) con.notify() con.release() def main(): for i in range(3): Producer().start() for i in range(2): Consumer().start() if __name__ == '__main__': from lib.excel import Excel from utils import settings for path, sheetnames in settings.SRC_DATA.items(): excel = Excel(path) sheet = excel.get_sheet(sheetnames[0]) for _i, _row in enumerate(sheet.rows): _t = excel.get_column(sheet, 'Year') print(1)