fastexcel icon indicating copy to clipboard operation
fastexcel copied to clipboard

Support for Reading Excel Tables

Open aersam opened this issue 11 months ago • 6 comments

From my experience it's usually much safer to load data from an excel table than from a sheet. would be nice if one could get the table names per sheet and get the table data as arrow/pandas like with the sheets

aersam avatar Mar 15 '24 14:03 aersam

Hi @aersam , could you please provide a bit more details on what you have in mind ? And maybe provide a few examples on how that parameter is passed in other libraries (for example pandas) ? A file with the issue you are encountering would also be great

lukapeschke avatar Mar 21 '24 14:03 lukapeschke

Hi there! Here's a sample file: tables.xlsx I'd like to pass the table_name instead of sheet_name, table name's are unique within an excel workbook as well:

image

aersam avatar Mar 21 '24 15:03 aersam

Thanks! This seems to be doable through calamine's APIs (https://docs.rs/calamine/latest/calamine/struct.Xlsx.html#method.table_by_name) but will require quite some work, so I don't know when/if we will ship it... We might pritoritize this if a lot of people ask for this feature :slightly_smiling_face:

lukapeschke avatar Mar 26 '24 13:03 lukapeschke

Thanks! This seems to be doable through calamine's APIs (https://docs.rs/calamine/latest/calamine/struct.Xlsx.html#method.table_by_name) but will require quite some work, so I don't know when/if we will ship it... We might pritoritize this if a lot of people ask for this feature 🙂

As a minor FYI, we always write "real" Excel table objects from Polars' write_excel method as they are generally considered quite useful, given how freeform Excel can otherwise be ;)

alexander-beedie avatar Apr 19 '24 20:04 alexander-beedie

@alexander-beedie ah good to know, thanks! How do you handle tables on read ? Is there a parameter to read a specific table ?

lukapeschke avatar Apr 22 '24 13:04 lukapeschke

@alexander-beedie ah good to know, thanks! How do you handle tables on read ? Is there a parameter to read a specific table ?

At the moment I don't, heh 😎 However, I was thinking about adding a table_name parameter, as one of our other engines (openpyxl) also supports reading table objects. If we could get an equivalent capability for fastexcel that would be really nice, as it completely eliminates the guessing game of "where does the data start/end" 👌

(You may also want an option to skip the final row when reading table objects, as that can contain totals that are not part of the data - they also may or may not have a header row, so the existing parameters to determine that can be respected).

alexander-beedie avatar May 01 '24 06:05 alexander-beedie