WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-27-2012, 12:33 PM
Lynnifer Lynnifer is offline
Member
 
Join Date: Feb 2012
Posts: 4
Question Help with File Reading/Writing

I am new to Vizard and Python, and I am having difficulty modifying a program used by a previous member of my lab for a new experiment I need to run. Specifically, I am getting an error that says:


File "<string>", line 12, in ?
File "Jen_OpFlow1_exp.py", line 408, in ?
tracking_data = open('Prism_VE Data_Dual Distortion_No Maze or Letters/headdata_'+ str(Subnum) + '.txt', 'a')
IOError: [Errno 2] No such file or directory: 'Prism_VE Data_Dual Distortion_No Maze or Letters/headdata_999.txt'


I believe this is the relevant section of code for the error:



tracking_data = open('Prism_VE Data_Dual Distortion_No Maze or Letters/headdata_'+ str(Subnum) + '.txt', 'a')
tracking_data2 = open('Prism_VE Data_Dual Distortion_No Maze or Letters/handdata_'+ str(Subnum) + '.txt', 'a')
#tracking_data3 = open('Prism_VE Data_Dual Distortion_No Maze or Letters/kneedata_'+ str(Subnum) + '.txt', 'a')
#tracking_data4 = open('Prism_VE Data_Dual Distortion_No Maze or Letters/ankledata_'+ str(Subnum) + '.txt', 'a')
#"""

flags = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y']
flagIndex = 0
def WriteFlag():
global flags, flagIndex
try:
letter = flags[flagIndex]
flagIndex = flagIndex + 1
tracking_data.write('*** Reached point ' + letter + '\n' + "*** Elapsed time =" + str( clock() - starttime) + " seconds \n")
tracking_data2.write('*** Reached point ' + letter + '\n'+ "*** Elapsed time =" + str( clock() - starttime) + " seconds \n")
tracking_data3.write('*** Reached point ' + letter + '\n'+ "*** Elapsed time =" + str( clock() - starttime) + " seconds \n")
tracking_data4.write('*** Reached point ' + letter + '\n'+ "*** Elapsed time =" + str( clock() - starttime) + " seconds \n")
print '*** Reached point ' + letter + '\n'+ "*** Elapsed time =" + str( clock() - starttime) + " seconds \n"
except IndexError:
print "Stop pressing 'f', you're out of flags"
vizact.onkeydown('f',WriteFlag)


What I need it to do is create and write the data to the file if it does not exist already, or to open and append to the file if it does already exist. Any advice would be greatly appreciated.
Reply With Quote
 


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
Closing of an imported .py file Uttama_vizard Vizard 2 05-04-2010 06:18 AM
IVEx file extenstion unrecognised. sindi Vizard 2 12-10-2009 01:20 AM
Read file....many issues Uttama_vizard Vizard 9 07-08-2008 02:16 PM
File Management Uttama_vizard Vizard 2 07-01-2008 09:44 AM
Closing file handles from within function FlyingWren Vizard 1 10-01-2003 06:02 PM


All times are GMT -7. The time now is 05:53 PM.


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