How to find the total number of rows and columns of an Excel spreadsheet in Python

Finding the total number of rows and columns returns the dimensionality of a spreadsheet while avoiding the time consuming process of iterating through each row individually. For example, a three by three array would have three rows and three columns.

Solution for How to find the total number of rows and columns of an Excel spreadsheet in Python : You can use pandas.DataFrame.shape to find the total number of rows and columns of an Excel spreadsheet Call ‘pandas.ExcelFile(file_name)’ to create an ExcelFile object from the file specified in file_name. Call ExcelFile.parse(sheet_name) with ExcelFile as the result of the previous step to select the sheet specified by sheet_name from ExcelFile and convert it into a pandas DataFrame. Now that the sheet is stored as a DataFrame, call pandas.DataFrame.shape to return a tuple where the first element is the number of rows and the second element is the number of columns.


how-to-find-the-total-number-of-rows-and-columns-of-an-excel-spreadsheet-in-python