简体   繁体   English

Pandas to_csv,文件只能用 LibreOffice 读取

[英]Pandas to_csv, file readable only with LibreOffice

I'm doing default Pandas read_excel, performing some actions on the dataframe, and at the end I'm saving the file:我正在做默认的 Pandas read_excel,对 dataframe 执行一些操作,最后我保存文件:

df.to_csv(target, index=False, compression='gzip', sep='|')

although the file is readable only with LibreOffice Calc -UTF-8, USA.尽管该文件只能使用美国的 LibreOffice Calc -UTF-8 读取。 If file is opened with Excel then I can see the filename in the first row / first column, and bunch of diamons with question marks in the other fields.如果使用 Excel 打开文件,那么我可以在第一行/第一列看到文件名,在其他字段中看到一堆带有问号的钻石。 Tried to set encoding in 'to_csv' for 'utf-8', 'utf-8-sig', 'utf-16' but nothing seems to work.尝试在“to_csv”中为“utf-8”、“utf-8-sig”、“utf-16”设置编码,但似乎没有任何效果。 How to make this file readable in Excel also?如何使该文件在 Excel 中也可读?

Thanks!谢谢!

Compression was the issue here.压缩是这里的问题。 Thanks!谢谢!

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

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