WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-25-2012, 02:33 AM
sxu04 sxu04 is offline
Member
 
Join Date: Dec 2011
Posts: 4
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:
				.....
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
reading USB I/O shuva93 Vizard 0 06-07-2011 01:37 PM
Using wordwrap or reading in newline (\n) comands from a .txt document EnvisMJ Vizard 1 04-04-2011 03:52 PM
Reading sensor data via UDP Jeethridge Plug-in development 1 08-24-2010 10:51 AM
Reading form serial port strangeness nige777 Vizard 6 06-22-2010 12:04 PM
csv reading kgarr Vizard 1 02-27-2006 12:02 PM


All times are GMT -7. The time now is 07:06 PM.


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