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

后端 未结 9 728
生来不讨喜
生来不讨喜 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:36

    What about:

    pandas.read_csv(PATH_TO_CSV, nrows=1).columns
    

    That'll read the first row only and return the columns found.

提交回复
热议问题