简体   繁体   English

Pandas “read_excel”:如何从“ods”文件中读取多行单元格?

[英]Pandas "read_excel" : How to read multi-line cell from "ods" file?

I've a simple "ods" file (Test01.ods) with the below data in "sheet1":-我有一个简单的“ods”文件(Test01.ods),在“sheet1”中有以下数据:-

在此处输入图像描述

also I saved it as "xlsx" (Test01.xlsx) so I've two files contains exactly the same data.我也将它保存为“xlsx”(Test01.xlsx)所以我有两个文件包含完全相同的数据。

Now when I try to read them using Pandas "read_excel" with the below code现在,当我尝试使用 Pandas "read_excel" 和下面的代码来阅读它们时

在此处输入图像描述

the "xslx" file is showing the line break char "\n" while the "ods" file does not. “xslx”文件显示换行符“\n”,而“ods”文件没有。

在此处输入图像描述

Any idea why?知道为什么吗? and how to force "odf engine" to output the "\n" to the dataframe?以及如何将“odf engine”强制到 output 将“\n”强制到 dataframe?

Thanks in advance提前致谢

As per this issue in Pandas's Github, this is an issue with the upstream "odfpy" package, our options are one of the following:根据 Pandas 的 Github 中的这个问题,这是上游“odfpy”package 的问题,我们的选项是以下之一:

  1. fix upstream (ideal) in odfpy在 odfpy 中修复上游(理想)
  2. modify the _get_cell_string_value method.修改 _get_cell_string_value 方法。

My workaround: save the "odf" file as "xslx" then work with it in pandas instead.我的解决方法:将“odf”文件保存为“xslx”,然后在 pandas 中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM