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

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

    you have missed nrows=1 param to read_csv

    >>> df= pd.read_csv(PATH_TO_CSV, nrows=1)
    >>> df.columns
    

提交回复
热议问题