Here is a code which should read your file and produce a python list of points. Check that it works.
colors = {
"ST": "green",
"SL": "red",
"OP": "black",
}
point_colors = {}
class Point(object):
"class for point objects"
def __init__(self, id, x, y, z):
self.id = id
self.x = x
self.y = y
self.z = z
@property
def color(self):
return colors[point_colors[self.id]]
def __repr__(self):
return "Point(%d, %f, %f, %f)" % (self.id, self.x, self.y, self.z)
def read_files():
"reads the files and return a list of points"
the_points = []
for line in open("Input_1"):
try:
L = line.strip().split()
if len(L) != 4:
continue
id, x, y, z = int(L[0]), float(L[1]), float(L[2]), float(L[3])
point = Point(id, x, y, z)
the_points.append(point)
except:
pass
for line in open("Input_2"):
try:
L = line.strip().split()
if len(L) != 2:
continue
id, col = int(L[0]), L[1]
point_colors[id] = L[1]
except:
pass
return the_points
the_points = read_files()
if __name__ == "__main__":
for point in the_points:
print repr(point)
From this, you must choose a graphic library to plot the points. I suppose that you want to plot the points only in 2D ? See if you can install matplotlib, which has simple commands and nice output.
http://matplotlib.sourceforge.net
Gribouillis
Posting Maven
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11