def read_excel_pgbar(excel_path, sheet_name, chunksize, usecols, dtype=object): try: # print('Getting row count of excel file') wb = load_workbook(excel_path, read_only=True) if type(sheet_name) == int: sheet = wb.worksheets[int(sheet_name)] else: sheet = wb[sheet_name] rows = sheet.max_row chunks = rows//chunksize + 1 print() # print('Reading excel file') chunk_list = [] for i in tqdm(range(chunks), desc='# Chunks read: '): tmp = pd.read_excel(excel_path, sheet_name=sheet_name, nrows=chunksize, skiprows=[k for k in range(i*chunksize)], usecols=usecols, dtype=dtype) chunk_list.append(tmp) myexcel = pd.concat((f for f in chunk_list), axis=0) print('Finish reading excel file') return myexcel except InvalidFileException: raise FileNotFoundError
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter