Help

python_3

#1

I am having trouble to calculate the distance between points inside list, (in Python)
this is my code and it says list index out of range:
import itertools
from math import *
import os

os.chdir("/Users/Hemanta/Desktop/")
oInput1 = open("super2_cell_bond_list_with_bond.txt", "r")
output = open("manup_data.txt", "w")

def euclidian_distance(x,y):
return float(sqrt(sum(float(math.pow(a-b,2)) for a, b in zip(x,y))))

for k in oInput1:
print "k is ", k
mInput1 = k.split()
print mInput1
print k.split()

-> p, q = float(mInput1[0]), float(mInput1[0])
fList1 += [(p,q)]
print "fLits1 is", fList1
output.write(str(mInput1))

The error is on the line by pointing arrow. I have attached my data set here.

ohh I tried to attach and it says new user cannot attach a file why? Here is my data, sorry for long one.
y =[[1.98777914 1.98777914 16.37576492]
[ 1.98777914 1.98777914 46.60876492]
[ 1.98777914 5.9633255 16.37576492]
[ 1.98777914 5.9633255 46.60876492]
[ 1.98777914 9.93887186 16.37576492]
[ 1.98777914 9.93887186 46.60876492]
[ 5.9633255 1.98777914 16.37576492]
[ 5.9633255 1.98777914 46.60876492]
[ 5.9633255 5.9633255 16.37576492]
[ 5.9633255 5.9633255 46.60876492]
[ 5.9633255 9.93887186 16.37576492]
[ 5.9633255 9.93887186 46.60876492]
[ 9.93887186 1.98777914 16.37576492]
[ 9.93887186 1.98777914 46.60876492]
[ 9.93887186 5.9633255 16.37576492]
[ 9.93887186 5.9633255 46.60876492]
[ 9.93887186 9.93887186 16.37576492]
[ 9.93887186 9.93887186 46.60876492]
[ 0. 0. 13.85723508]
[ 0. 0. 44.09023508]
[ 0. 3.97554636 13.85723508]
[ 0. 3.97554636 44.09023508]
[ 0. 7.95110464 13.85723508]
[ 0. 7.95110464 44.09023508]
[ 3.97554636 0. 13.85723508]
[ 3.97554636 0. 44.09023508]
[ 3.97554636 3.97554636 13.85723508]]

First I tried to manipulate the list as [[1,2,3], [4,5,6]....] . I mean my list is not well formatted, so I tried to do that. I will have more than 1000 points in my data set in such format. Any help will be really appreciated.


#2

What's the trouble though? What's stopping you? What's the question?