'Python - Automatically detecting headers in excel

I'm attempting to write a generic program that can detect and ignore headers. I have one dataset with a two-row header followed by the data values, and another with a single row header. How can I dynamically determine the total number of headers in each file and skip those? I can't use Sniffer because it is not a CSV file.

df = pandas.read_excel('ExcelFile.xlsx', header=[0, 1]) 

This considers both 0th and 1st row as header, where as my requirement is to automatically the program has to detect total number of headers present. How can I solve this issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source