You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
772 B
31 lines
772 B
""" some helper functions """ |
|
|
|
import openpyxl |
|
|
|
|
|
def get_sheet_of_file(excel_file, sheet=None): |
|
""" returns a sheet from an excel FileCache |
|
|
|
if name is set to None, the function returns the first sheet |
|
""" |
|
workbook = openpyxl.open(excel_file) |
|
if sheet is None: |
|
all_sheets = workbook.sheetnames |
|
sheet = all_sheets[0] |
|
return workbook[sheet] |
|
|
|
|
|
def is_empty_excel_value(value): |
|
""" is the cell value considered empty """ |
|
if value is None: |
|
return True |
|
if isinstance(value, str) and value.strip() == "": |
|
return True |
|
return False |
|
|
|
|
|
def strip_excel_value(value): |
|
""" remove whitespace from an excel value if it is a string """ |
|
if isinstance(value, str): |
|
return value.strip() |
|
return value
|
|
|