How can I read only the header column of a CSV file using Python?

后端 未结 9 718
生来不讨喜
生来不讨喜 2020-12-14 10:05

I am looking for a a way to read just the header row of a large number of large CSV files.

Using Pandas, I have this method available, for each csv file:

         


        
9条回答
  •  不思量自难忘°
    2020-12-14 10:39

    it is easy you can use this:

    df = pd.read_csv("path.csv", skiprows=0, nrows=2)
    df.columns.to_list()
    

    In this case you can only read really few row for get your header

提交回复
热议问题