ToucanToco / fastexcel

A Python wrapper around calamine
http://fastexcel.toucantoco.dev/
MIT License
82 stars 4 forks source link

Support for Reading Excel Tables #204

Open aersam opened 3 months ago

aersam commented 3 months ago

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

lukapeschke commented 3 months ago

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

aersam commented 3 months ago

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

lukapeschke commented 3 months ago

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:

alexander-beedie commented 2 months ago

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 ;)

lukapeschke commented 2 months ago

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

alexander-beedie commented 2 months ago

@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).