Hi folks - I think I'm almost there...
I have files with data in this format:
ID1 ID2 Dist
1 a 50
2 b 20
3 c 10
2 c 100
4 c 80
4 a 70
1 a 90
2 a 34
3 b 5
2 b 6
1 a 12
1 c 12
4 a 14
I need to find the minimum value for Dist based on ID2, i.e. what is the minimum Dist value for set a, b, c and d.
I have the following, but I clearly need help...
1) I'm currently reading each line of an input file into an array, but in reality the input file is so huge that this would not be practical - I need to somehow process each line of the file without holding the entire file in temporary storage.
2) I'm trying to split each line of this array generated from readlines into separate columns, but I don't know how to do this properly.
3) I think I'm onto the ultimate solution with the line "value=...", but it's the preceding steps that are flummoxing me.
fin = open( "input.txt", "r" ) count=0 datalist=fin.readlines() for line in datalist: count=count+1 datalist[count] = line.split() x=line y=line z=line value = min(z for z in datalist if y = a) fout = open("output.txt", "w") fout.writelines(value)
Edited 6 Years Ago by Stubaan: n/a