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