Row count in a csv file

后端 未结 5 1571
情深已故
情深已故 2020-12-01 20:31

I am probably making a stupid mistake, but I can\'t find where it is. I want to count the number of lines in my csv file. I wrote this, and obviously isn\'t working: I have

5条回答
  •  一整个雨季
    2020-12-01 21:32

    # with built in libraries
    opened_file = open('f.csv')
    from csv import reader
    
    read_file = reader(opened_file)
    apps_data = list(read_file)
    
    rowcount = len(apps_data) #which incudes header row
    
    print("Total rows incuding header: " + str(rowcount))
    

提交回复
热议问题