Wednesday, 2 October 2013

turn a list of strings into a list of xyz cooridnates python

turn a list of strings into a list of xyz cooridnates python

First off i will start by saying I am new to python so any help will be
greatly appreciated.
I have a .dat file that is in the following format
J
366 -1722 583
366 356 1783
866 789 1033
866 -1289 -167
366 -1722 583
J
-500 -1472 150
0 -1039 -600
0 1039 600
-500 606 1350
-500 -1472 150
The numbers are xyz coordinates and the J represents a Jump bit so every
time the J occurs I need to lift the pencil and go to the next point to
continue drawing.
I want to read this file into a python file and store the values in a list
as xyz coordinates so i can draw lines from them using pygame.
So far i can read the file into a list using this code
file = open('file.dat', 'r')
vlist = file.readlines()
file.close
Thanks in advance for any help

No comments:

Post a Comment