How to ignore the first line of data when processing CSV data?

前端 未结 17 2286
庸人自扰
庸人自扰 2020-11-22 10:05

I am asking Python to print the minimum number from a column of CSV data, but the top row is the column number, and I don\'t want Python to take the top row into account. Ho

17条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 10:46

    For me the easiest way to go is to use range.

    import csv
    
    with open('files/filename.csv') as I:
        reader = csv.reader(I)
        fulllist = list(reader)
    
    # Starting with data skipping header
    for item in range(1, len(fulllist)): 
        # Print each row using "item" as the index value
        print (fulllist[item])  
    

提交回复
热议问题