I want to get output as:
[Randy, Shaw]
Output Looks like
['Randy', 'None', 'None', 'Shaw', 'None', 'None']
But it is not removing 'None' values.
Here is my code..
from openpyxl import load_workbook
workbook = load_workbook('C:/Users/Desktop/test.xlsx')
print(workbook.get_sheet_names())
sheet=workbook.get_sheet_by_name('marks')
iterheaders = iter(sheet[1])
headers = [str(cell.value) for cell in iterheaders if cell is not None and cell != '']
Keyword_list = list(filter(None, headers))
I even tried the following but it didn't work either:
Keyword_list = [i for i in headers if (None) != len(i)]
Q2. In the same code what if I want to get the sheet by its index rather than by its name in openpyxl. How do I do that?