Hi All ,<br><br>Could any one help to get max and min values from a specified column of a csv file. The<b> csv file is large</b> and hence the below code did go bad. <b>Alternate methods would be highly appreciated<br></b><b><br>
minimum.py</b>:<br>import csv<br>filename = "testLog_4.csv"<br>f = open(filename)<br>def col_min(mincname):<br> with open(filename, 'rb') as f:<br> reader = csv.reader(f, delimiter=",") <br>
#print reader<br> #print mincname<br> col_index = next(reader).index(mincname)<br> #print col_index<br> least = min(rec[col_index] for rec in reader)<br> print least<br> <br>col_min(str("Server Latency"))<br>
col_min(str("Client Latency"))<br>f.close()<br><br><b>maximum.py:</b><br>import csv<br>filename = "testLog_4.csv"<br>f = open(filename)<br>def col_max(maxcname):<br> with open(filename, 'rb') as f:<br>
reader = csv.reader(f, delimiter=",")<br> #print reader<br> #print cname<br> col_index = next(reader).index(maxcname)<br> #print col_index<br> highest = max(rec[col_index] for rec in reader)<br>
print highest<br> <br>col_max(str("Server Latency"))<br>col_max(str("Client Latency"))<br>f.close()<br><br><br>Thanks<br><br>