如何通过使用Python对CSV文件中的日期进行排序来获得列中的最高值?
我的代码:
if sys.argv[1] == "-p":
c = sys.argv[2]
col_name= r"\\DT001\Process(SK)\Virtual"
#d = sys.argv[3]
col_name2 = r"(PDH-CSV 4.0) (GMT Standard Time)(0)"
with open(c, 'rb') as inf:
reader = csv.reader(inf)
col_index = next(reader).index(col_name)
highest = float(max(rec[col_index] for rec in reader))
reader2 = csv.reader2(inf)
col_index2 = next(reader).index(col_name2)
date = '7/19/2011'
#gigabytes = highest / 1073741824
gigabytes = highest /1024/1024/1024
print "Performance Counters Peak:\n", gigabytes, "GB"我能够对最高值进行排序,但我无法弄清楚如何通过使用Python脚本在CSV文件中对期望的日期进行排序来获得最高值。