WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 12-05-2017, 07:13 AM
Vishav Vishav is offline
Join Date: Jun 2017
Posts: 57
Error in file opening Vizard

Dear all,

I am getting this error in my code when i am opening file in append mode:

Traceback (most recent call last):
File "C:\Program Files\WorldViz\Vizard5\python\", line 752, in updateAndKillOnException
return self.update()
File "C:\Program Files\WorldViz\Vizard5\python\", line 719, in update
val = self._stack[-1].send(sendData)
File "", line 50, in task1
IOError: [Errno 22] invalid mode ('a') or filename: '<built-in function id>_experiment_data.txt'

My Source Code:

global experiment_data
filename=str(id) +'_experiment_data.txt'
experiment_data = open(filename,'a')
print str(id)
I am getting exporting id value from other code

Please help me in it.
Reply With Quote
Old 12-06-2017, 12:33 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,470
It looks like the file is not found. Does the following work?

directory = r'D:\PhD\Study-I_Part_I\My_Programs\DFI\Participant_Data'
filename = str(id) + '_experiment_data.txt'
filepath = os.path.join(directory, filename)
experiment_data = open(filepath,'a')
Reply With Quote
Old 12-06-2017, 06:48 AM
Vishav Vishav is offline
Join Date: Jun 2017
Posts: 57
Same error is coming with code suggested by you.

I will explain it
I have one file called Parent in which i created file experiment_data having write mode using code.

experiment_data = open(str(id) + '_experiment_data.txt','w')
data = " Participant ID: %s\tParticipant Name: %s\tAge: %s\tGender: %s\n\n" % (id,Name,Age,gender)

After that i made a child code to which i passed id variable value to child using code
myVars = {'id':id}
exec(open('').read(), myVars)

Then I open experiment_data file in child code matching with id value in append mode using code

filename=str(id) +'_experiment_data.txt'
experiment_data = open(filename,'a')

This error is coming when Parent code import child code. I don't know where i am going wrong.
Reply With Quote
Old 12-06-2017, 11:09 AM
Vishav Vishav is offline
Join Date: Jun 2017
Posts: 57
File Handling

If i open file every time i need to write data then this error not comes but then new problem came that is infobox.remove() is not working. Adding snapshot for reference.
Source Code:
if radio1.get() == viz.DOWN:

os.chdir(r'D:\PhD\Study-Click image for larger version

Name:	Capture1.JPG
Views:	318
Size:	28.7 KB
ID:	964I_Part_I\My_Programs\DFI\Participant_Data')

experiment_data = open(str(id) + '_experiment_data.txt','a')

feedback = viz.addText('You are doing Great!',viz.SCREEN)
Reply With Quote
Old 12-07-2017, 09:53 PM
Vishav Vishav is offline
Join Date: Jun 2017
Posts: 57
I figured it out... Thanks
Reply With Quote

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
.wrl File in Vizard Hitesh Vizard 2 07-02-2015 09:43 AM
Converting .blend file in .osgb or any vizard supported file Hitesh Vizard 0 07-02-2015 01:31 AM
Vizard .exe file doesn't load (Vizard 3) Saule Vizard 4 02-05-2014 06:01 AM
Interaction of vizard objects with an imported obj file sunil.nair Vizard 2 10-09-2013 02:08 PM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM

All times are GMT -7. The time now is 06:04 AM.

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