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

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

    import pandas as pd
    
    get_col = list(pd.read_csv("first_test_pipe.csv",sep="|",nrows=1).columns)
    print(get_col)
    

提交回复
热议问题