WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Reading in columns (https://forum.worldviz.com/showthread.php?t=4125)

sxu04 01-25-2012 02:33 AM

Reading in columns
 
Hi, I'm hoping someone can help

I have a text file that I need to read in, and I want to be able to loop through both rows and columns

Column 1 and 2 in the text file contains a list of 64 numbers relating to 64 x and y positions. Column 3 contains a list of 64 numbers (either 1 or 2) that relates to a certain action in my vizard code.

Currently, I can loop through each row in columns 1 and 2 checking whether these values match their current position, when it matches - the number in the corresponding row in column 3 is read in and the action is carried out.

So far so good, but rather than having just one 'action' column I actually have 100+ action columns (columns 3 -100+) and I want to create a loop where each step in the loop reads the next action colomn in the text file

Any help would be most appreciated!

Code:

import viz
viz.go()

currentX=[]
currentY=[]
action=[]

file = open('data.txt', 'r')

for line in file:
        s=line.split()
        currentX.append(float(s[0]))
        currentY.append(float(s[1]))
        action.append(float(s[2]))
       
def movement(key):
        currentpos = viz.MainView.getPosition()               
        for i in range(0,64):       
                if currentpos==[currentX[i],1.0,currentY[i]]:
                        if action[i]==1:
                                .....



All times are GMT -7. The time now is 01:41 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC