从Apache Zeppelin复制/粘贴时不保留换行符



我正在使用pandasto_csv()函数在Zeppelin (MacOS 10.14.6, Google Chrome, pyspark, Python 3.6.8)中打印csv,当我将结果复制并粘贴到另一个应用程序(例如Excel, Google Sheets, Apple Notes)时,它都出现在一行上。我尝试过使用to_csv(line_terminator='rn')(例如)更新换行符,但我也没有尝试过。

但是,当我将结果复制并粘贴到VIM中时,保留了换行符。为了弄清楚那里有什么换行符,我用-b运行VIM并使用:set list-我在每行末尾看到的都是$

我做错了什么?

try this

with open(file_path, mode='w', newline='rn') as f:
data_frame.to_csv(f, index=False)

最新更新