'Define dimension of the matrix of excel data set imported

I'm importing in Autodesk Dynamo with a Python script some data from an excel file.

data = pd.read_excel (file str, sheet_name='Sections')
mat = data.values.tolist()
header = list(data.columns.values)

With some Excel I have an error from Dynamo because I don't have control on the dimension (numbers of rows and column) of the sheet that I'm importing, causing an error when I have empty cells or null value.

Can anyone help me to improve this code

mat = data.values.tolist()

allowing me to manage and import a precise number of rows and columns (those with values)?

Thanks



Sources

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

Source: Stack Overflow

Solution Source