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

前端 未结 17 2205
庸人自扰
庸人自扰 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:32

    Borrowed from python cookbook,
    A more concise template code might look like this:

    import csv
    with open('stocks.csv') as f:
        f_csv = csv.reader(f) 
        headers = next(f_csv) 
        for row in f_csv:
            # Process row ...
    

提交回复
热议问题