Skip to content

BUG: Comment in ODS-file gets included in string cells #55727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

dimastbk
Copy link
Contributor

This PR fixes only annotations in string cell. For time cell see #55324.

@dimastbk dimastbk requested a review from rhshadrach as a code owner October 27, 2023 13:06
@mroeschke mroeschke added the IO Excel read_excel, to_excel label Oct 27, 2023
@@ -239,6 +241,8 @@ def _get_cell_string_value(self, cell) -> str:
if fragment.qname == text_s:
spaces = int(fragment.attributes.get((TEXTNS, "c"), 1))
value.append(" " * spaces)
elif fragment.qname == office_annotation:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the cell value is the same as a cell comment, does this still work correctly?

Copy link
Contributor Author

@dimastbk dimastbk Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for files from LibreOffice at least:
image
get_sheet_data output: [['Column 1'], ['test'], [''], ['test 3']]
dataframe:

Column 1
0     test
1      NaN
2   test 3

It is because table:table-cell doesn't contain office:value-type attribute and the type of cell is None, so we don't check office:annotation.

I added a test.

@mroeschke mroeschke added this to the 2.2 milestone Oct 30, 2023
@mroeschke mroeschke merged commit cb0a11e into pandas-dev:main Oct 30, 2023
@mroeschke
Copy link
Member

Thanks @dimastbk

@dimastbk dimastbk deleted the issue55200 branch November 1, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Comment in ODS-file gets included in string cells
2 participants