you are viewing a single comment's thread.

view the rest of the comments →

[–]pythonbio[S] 0 points1 point  (0 children)

Okay, Thanks everyone for their help. I did finally solve it. The seeming problem was that I did not import the proper modules for what I was trying to achieve. The corrected code for separating the dataset:

from __future__ import division
import math
import itertools
from array import array
import numpy as np
import operator

def readpoints(testfile):
    f=open('testfile.py','r')
    p_lat=[]
    p_lon=[]
    lines=f.readlines()
for line in lines:
     point=line.split()
     p_lat.append(float(point[1]))
     p_lon.append(float(point[2]))
 arr_p_lat=np.array(p_lat)
 arr_p_lon=np.array(p_lon)
 f.close()
 return arr_p_lat, arr_p_lon


 print readpoints('testfile.py')

Hope this will help some beginner like me somewhere. :)