chore: xlsx improvements#52
Conversation
@microsoft-github-policy-service agree [company="{your company}"] |
@microsoft-github-policy-service agree |
|
@hewliyang thanks for the PR. cc @afourney |
|
If the objective is beautification, what is we added a |
thank for for reviewing @gagb 🤗 well, the right answer is that it is non-trivial because we would have to curate a QA test set and run experiments on it. but what I do know for sure is having
sounds good! |
|
For empty values, "" is definitely better than NaN. Although I'm not sure if we want to remove empty columns, that would be transforming the structure of the data. - maybe this can be a flag, such as |
sounds good. my idea of when we would want to keep fully null rows/cols is such as when there are subtables in a sheet & we want to maintain some spatial seperation (or not). added two flags also am now fowarding |
|
Arguably, if the xlsx cell is empty, the conversion should be empty. If the excel value is "#N/A" then I believe it should be interpreted as NaN (though it's perhaps not exactly the same). In any case, I agree with dropping completely empty columns (including empty headers), and with encoding empty cells with "". I'm not sure what to do about column headers yet. Let me think on this more, and test with #N/A values. |
I've pushed a change to:
Additionally:
Regarding
Not sure how verbose you would want the tests to be, because I think for the latter we will need to reparse the string representation. Also I see a related PR #169. If we intend to merge this then another todo would be to wrap all the |
|
Thanks for adding the --drop flags!
Excel supports ~1.048m rows max, but in my experience it starts to get sluggish with a sheet over 100k, but that's another story. On the pandas using too much memory topic - I'm generally advocating for all projects to replace pandas with polars or duckdb whenever it's possible, especially when working with large datasets. I'm actual planning to open a PR myself in January, to replace all pandas functions with polars whenever it's possible, as I'm expecting this library will be used to convert vast amounts of data, we should make this as efficient as possible. |
|
Is there any progress on this? The patch for replacing "NaN" with "" in the MD would be really important. |
|
Not yet, but let me prioritize it for this week. I'm not sold on removing columns, or headers... but swapping NaN for "" make a lot of sense to me |
Totally agree .. removing columns or headers should probably be something that would be better optional, to be enabled by a command line / API parameter option, but the NaNs are surprising if a cell is simply just empty. Personally I very much like it when a utility like this one allows the user to choose such things via command line parameters or API parametrization, especially this tool can be used for many purposes. |
|
Sounds good. This PR has drifted from when it was submitted. Let me try to migrate the "NaN" -> "" bits to the new main branch, and we can add further refinements in another PR. |
I believe the current implementation already satisfies your requirements:
I've updated it to match the latest HEAD @afourney. Please have a look at the updated PR description. The changes should apply what you wanted to cherry pick by default - and not apply what I've proposed by default- but the option is there for the user. Only thing is I don't see a clear way to communicate these options as it is. CLI also isn't compatible with arbitrary kwargs right now. |
|
Any update to this PR? |
For me now it's clear that Microsoft needs those NaNs to increase stakeholder satisfaction. edit: last meaningful merge #1865 was on may 22, so we can also consider this repo dead but at least understaffed |
updates Apr 3 2025
added the following kwargs to Excel-like converters
na_rep=""Unnamed:{i}is scrubbed out by default tona_rep=""sparsity options:
also refactored Xlsx and Xls parsers to be more DRY with a ExcelParser base class. this will make it easier to
calamineinstead. see Feature: Support XLSM, XLSB & Replace excel engine with faster calamine #259usage
Old
a couple simple heuristics that should be safe to apply in any general case:
Unnamed_{i}and I think we can scrub this outExamples
here is what I have expanded the
test.xlsxto look like (changes annotated in red):which would produce:
Sheet1
09060124-b5e7-4717-9d07-3c046eb
with the changes:
Sheet1
09060124-b5e7-4717-9d07-3c046eb