在Windows中将CSV文件读取到

在Windows中将CSV文件读取到

本文介绍了在Windows中将CSV文件读取到 pandas ,而不是在ubuntu中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Windows在python中编写了一些脚本,并希望在Ubuntu的树莓派中运行它.

I have written some scrip in python using windows and want to run it in my raspberry with Ubuntu.

我正在读取带有换行符的csv文件.加载df时,我使用以下代码:

I am reading a csv file with line separator new line. When I load the df I use the following code:

dfaux = pd.read_csv(r'/home/ubuntu/Downloads/data.csv',sep =';')

加载只有一行的df.我还尝试过包含参数 lineterminator ='\ n \ t',该参数会引发以下错误消息:

which loads a df with just one row. I have also tried including the argument lineterminator = '\n\t' which throws this error message:

ValueError:仅支持长度为1的行终止符

ValueError: Only length-1 line terminators supported

在Windows中,我看到csv文件中的换行符,而当我在ubuntu中用鼠标垫打开它时,我看不到换行符,但是我看到了彩色编码的列.

In windows I see the line breaks in the csv file, whereas when I open it with mousepad in ubuntu I don't see the line breakers, but I see the columns color coded.

我如何正确阅读csv?

How could I read properly the csv?

谢谢!

推荐答案

好吧,最后我通过使用浏览器更改了使用浏览器将csv文件从Firefox下载到Chrome的浏览器,从而解决了该问题,但不知道这是什么.原因,但如果将来您遇到相同的问题,这可能会有所帮助

Well, at then end I solved it by changing the explorer I was using to download the csv file with webdriver from Firefox to Chrome, not sure what´s the reason behind but maybe this will help if you have the same issue in the future

这篇关于在Windows中将CSV文件读取到 pandas ,而不是在ubuntu中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:54