-
Notifications
You must be signed in to change notification settings - Fork 22
Pulling Named Range or ListObject (e.g. Table) Values Into DataFrame or Nested List #19
Description
Goal
- Read the values from an Excel named range into a nested list like [[1,2,3],[10,20,30]] or Pandas dataframe
- Read the values from an Excel table into a nested list or Pandas dataframe
Description
It would be extremely useful to add a method to pull the contents of an entire name range or table (e.g. listobject in VBA) directly into a nested listed (a matrix such as [[1,2,3], [10,20,30]] or a Panda's dataframe.
I see reading data from XLSB files as one of the primary use cases of this library, and introducing what I am proposing would make using this package much easier. What I am describing can be done easily using XLWings, but this package is specific to Windows and requires Excel to be installed. This pretty much kills XLWings as an option for server-side applications or for deployments on Linux.
Suggested API
Assume wsht and wbk have been initialized to a worksheet and workbook respectively.
DataFrameQ: Optional[bool] = True in each of the functions forces a dataframe to be return. By default, the functions should return nested lists.
I see the need for the following three methods:
-
From a Worksheet Named Range - Should work with both the name of the ranges or a standard address
Call: wsht.GetRangeValues(rangeName: str, DataFrameQ: Optional[bool] = False)
Returned Value : [[val_1_1, val_1_2, ...], [val_2_1, val_2_2, ...], ...] -
From a Workbook Named Range - Should work with both the name of the ranges or a standard address
Call: wbk.GetRangeValues(rangeName: str, DataFrameQ: Optional[bool] = False)
Returned Value : [[val_1_1, val_1_2, ...], [val_2_1, val_2_2, ...], ...] -
From a Table - Need only work with table names
Call: wsht.GetTableValues((tableName: str, DataFrameQ: Optional[bool] = False)
Returned Value : [[val_1_1, val_1_2, ...], [val_2_1, val_2_2, ...], ...]
Sincerely,
Pablo