如何读取大型csv文件并分别读取每一列?

问题描述 投票:0回答:1

我有一个很大的CSV文件,我将其作为数据帧读取。但我不知道如何按每一列分别阅读。

我尝试使用sep = '\',但它给我一个错误。

我使用以下代码读取了文件:

filename = "D:\\DLR DATA\\status maritime\\nperf-data_2019-01-01_2019-09-10_bC5HIhAfJWqdQckz.csv"


#Dataframes implement the Pandas API
import dask.dataframe as dd
df = dd.read_csv(filename)
df1 = df.head()

当我打印数据框头时,我得到以下结果:

enter image description here

在变量浏览器中,我的数据框仅包含1列,其中所有数据都在其中:

enter image description here

我尝试将sep = ''设置为空格和逗号。但这没有用。如何使用适当的不同列读取所有数据?我将不胜感激。

python-3.x csv dataframe readfile
1个回答
0
投票

您有一个用制表符分隔的文件,请使用\t

df = dd.read_csv(filename, sep='\t')
© www.soinside.com 2019 - 2024. All rights reserved.