Skip to content
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

Linebreaks not picked up #114

Open
baloe opened this issue Jan 21, 2022 · 6 comments
Open

Linebreaks not picked up #114

baloe opened this issue Jan 21, 2022 · 6 comments

Comments

@baloe
Copy link

baloe commented Jan 21, 2022

Linebreaks within a text cell are not read.

Here's a small example:
doc_content
I saved this sheet as doc.ods and doc.xlsx.

The following script

#!/usr/bin/env python3

import pandas as pd

print('\nRead with odf:'):
data = pd.read_excel( 'doc.ods', engine='odf' )
print(data)

print('\nRead with openpyxl:'):
data = pd.read_excel( 'doc.xlsx', engine='openpyxl' )
print(data)

prints

Read with odf:
                   testdata
0  cell without a linebreak
1    cell with a line break

Read with openpyxl:
                   testdata
0  cell without a linebreak
1  cell with \na line break

lacking the newline character \n in the pandas dataframe produced through odf.

Versions:

# Name                    Version                   Build  Channel
pandas                    1.3.5            py38h43a58ef_0    conda-forge
odfpy                     1.4.1                      py_0    conda-forge
@Obsnold
Copy link

Obsnold commented Mar 25, 2022

I just had the same issue.
Here is an example just using odfpy

#!/usr/bin/env python3

import sys
from odf.opendocument import load
from odf.table import Table, TableRow, TableCell

infile = sys.argv[1]
doc = load(infile)

cell= doc.getElementsByType(Table)[0].getElementsByType(TableRow)[2].getElementsByType(TableCell)[0]

print(cell)

Using the same spreadsheet as above you get the output:

cell with A line break

@achaiah
Copy link

achaiah commented Apr 21, 2022

Yes, same issue here. Is there a fix?

@Tuhin-thinks
Copy link

Index Col\nNext Line is getting read as Index ColNext Line

Checked in version: 1.4.1

@buhtz
Copy link

buhtz commented Apr 2, 2024

Please see #123 about the project status. The project is nearly orphaned.

@Tuhin-thinks
Copy link

Sorry to see that this project has gone stale.

Will explore jdum/odfdo as referenced in #123

Thanks 👍🏻

@Icemole
Copy link

Icemole commented Oct 2, 2024

Thanks for the report, the issue was driving me crazy. Sadly, odfdo doesn't seem to be a drop-in replacement for odfpy. I'll stick to using openpyxl for now. Thank you everyone who contributed to the thread!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants