Search code examples
pythonexcelfile-read

Shortest code to load an excel sheet with header?


I have an excel file, from which I want to load a specific sheet. Assuming I know its name, and that there is only one row of header, what is the shortest code capable of doing this?


Solution

  • Using pandas' read_excel function you can do this:

    import pandas as pd
    df = pd.read_excel(FILENAME)
    

    Your document will load into the df dataframe.

    There are additional options you can pass to read_excel if you need to skip rows, manipulate headers, parse dates, etc. too.