python - Check if a Excel Sheet is empty -


i have excel workbook multiple sheets. need delete sheets empty, code when processing finds blank sheet fails.

os.chdir(path) list_file=[] file in glob.glob("*.xlsx"):     print(file)     list_file.append(file) 

i have listed files here available.

ab_list=[s s in list_file if "india" in s] cd_list=[s s in list_file if "japan" in s] 

then, store file names list per requirement. need delete empty sheets excel files before move them dataframe. loop through read files individual dataframe.

you've tagged openpyxl assume you're using that.

# workbook opened ms exel sheet opened openpyxl.workbook empty_sheets = [] name in workbook.get_sheet_names():     sheet = workbook.get_sheet_by_name(name)     if not sheet.columns():         empty_sheets.append(sheet)  map(workbook.remove, empty_sheets) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -