So what I am trying to do is I have a csv file that looks like this:
"test_name", "Mean", "Median", "Std_Dev"
"Data Name 1", 50, 75, 10
"Data Name 2", 52, 80, 11
"Data Name 1", 53, 79, 9
"Data Name 2", 55, 78, 8
"Data Name 3", 54, 77, 7
"Data Name 3", 53, 71, 7
"Data Name 1", 51, 72, 8
So right now, I have a program that finds if the test name is equal to each other. Because if they have the same Data Name, I want to compare the data they have.
import csv
csvfile = 'some.csv'
data = {}
with open('some.csv') as f:
reader = csv.DictReader(f)
for row in reader:
for (k,v) in row.items():
try:
data[k].append(v)
except KeyError:
data[k] = [v]
testNames = data['test_name']
mean = data['Mean']
median = data['Median']
std = data['Stdev']
for val in testNames:
for val2 in testNames:
if val == val2:
index = testNames.index(val)
index2 = testNames.index(val2)
medianTemp = median[index]
medianTemp2 = median[index2]
if medianTemp2 > medianTemp:
sub = medianTemp2 - medianTemp
if sub > 100:
print "Uh oh! @ ", val, "and ", val2 names only
Maybe, I'm doing something a little far off here. I am just looking to compare the medians of the data that has the same test name. I am struggling with being able to get the row data comparison after I have already compared the test_names. I have that part working.
******* EDIT ********* I am trying to use index() to find the element location now.
Now the issue that I am having is the index and index2 are the exact same value. Rather than Data Name 1 giving index 0 and the next Data Name 1 giving an index2 of 2. They both give 0.
Any suggestions are greatly appreciated.
Thanks :)