Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.26 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to open a CSV,read a particular header of column and get the highest value
  2. import csv
  3. col_name = "name"
  4. with open("file.csv", "rb") as f:
  5.     reader = csv.reader(f)
  6.     col_index = next(reader).index(col_name)
  7.     highest = max(rec[col_index] for rec in reader)