I'm trying to compare each number from a list to an set of elements in a column from a dictionary, if value from list is between a range from one of the elements of the column from a dictionary I want to ad it's correspondent from another column to a new list.
Current result is not adding all corresponding values or doing un expecting additions
Here some of my code, current results are not as expected
#Open CSV file as a dictionary
fname2=input('Enter Tme vs Depth File name ')
with open(fname2, 'r') as csv_file2:
handler2=csv.DictReader(csv_file2)
temp=[]
#Arr = Array with the comparisson values, first input
for n in Arr:
m=float(n)
#limits for the range
x=m-0.5
y=m+0.5
for line in handler2:
if (float(line['Date/Time']) > x) and (float(line['Date/Time']) < y) :
if float(line['RSSDEP_CONT_RT']) in temp:
continue
else:
temp.append(float(line['RSSDEP_CONT_RT']))
# print New list
print (len(temp))
Thanks in advance
question from:
https://stackoverflow.com/questions/65682812/compare-one-by-one-a-float-number-from-a-list-to-a-column-in-a-dictionary-betwee 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…