How to read a specific line number in a csv with pandas

后端 未结 4 2040
盖世英雄少女心
盖世英雄少女心 2021-01-18 10:46

I have a huge dataset and I am trying to read it line by line. For now, I am reading the dataset using pandas:

df = pd.read_csv(\"mydata.csv\", sep =\',\', n         


        
4条回答
  •  醉梦人生
    2021-01-18 11:25

    Looking in the pandas documentation, there is a parameter for read_csv function:

    skiprows
    

    If a list is assigned to this parameter it will skip the line indexed by the list:

    skiprows = [0,1]
    

    This will skip the first one and the second line. Thus a combination of nrow and skiprows allow to read each line in the dataset separately.

提交回复
热议问题