WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 05-04-2006, 03:23 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
I created this data file but one question I had was whether there was a way to place Headings at the beginning of the file. If you notice right now, there is text (eg 'male count', 'female count', etc) before the actual data used to identify the data that is being shown during a question_data.write() command. Is there a way to only put those headings at the beginning of the data file instead of having them included in the write command. I hope I'm being clear. Here is an example I typed out (attachment)

Code:
#Mark the time that the program was started.
start_time_sec = time.time()
start_time_clock = time.ctime()
#Open a file to collect the data on this subject.
question_data = open('omar_data','a')
#Get the data from the button press.
def mykey(key):
 global autospawn, soldierCount, maleCount, femaleCount
 if key == 'a':
  autospawn = not autospawn
  if autospawn:
   viz.starttimer(SPAWN_TIMER,GetSpawnTime())
  else:
   viz.killtimer(SPAWN_TIMER)
 elif key == 's':
  StartAvatar(randint(0,5))
 elif key == 'q':
  miss_count = bulletCount - avatarsHit
  #print "miss count is", miss_count
  #Use our starting time variable to find out how much
  #time has elapsed.
  elapsed_time_sec = time.time() - start_time_sec
  #elapsed_time_clock = time.ctime(elapsed_time_sec) + time.ctime(start_time_sec)
  final_time_sec = start_time_sec + elapsed_time_sec
  final_time_clock = time.ctime(final_time_sec)
  #Create string lines to put in the data file, depending on which button was pushed.
  subject_data = str(subject) + '\t'  
  start_data = str(start_time_clock) + '\t'
  final_time_data = str(final_time_clock) + '\t'
  avatar_hit_count = str(avatarsHit) + '\t'
  bullet_count_data = str(bulletCount) + '\t'
  miss_count_data = 'miss count ' + str(miss_count) + '\t'
  soldier_Count_data = 'soldier count ' + str(soldierCount) + '\t'
  male_Count_data = 'male count ' + str(maleCount) + '\t'
  female_Count_data = 'female count ' + str(femaleCount) + '\t'  
  threat_Count_data = 'threat count ' + str(threatCount) + '\t'
  nonthreat_Count_data = 'nonthreat count ' + str(nonthreatCount) + '\t\n'
  question_data.write(subject_data)  
  question_data.write(start_data)
  question_data.write(final_time_data)
  question_data.write(avatar_hit_count)
  question_data.write(bullet_count_data)
  question_data.write(miss_count_data)
  question_data.write(soldier_Count_data)
  question_data.write(male_Count_data)
  question_data.write(female_Count_data)
  question_data.write(threat_Count_data)
  question_data.write(nonthreat_Count_data)  
  #Flush the internal buffer.
  question_data.flush() 
  #Close the world.
  viz.quit()
viz.callback(viz.KEYBOARD_EVENT,mykey)
Attached Files
File Type: txt example.txt (484 Bytes, 6296 views)
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


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


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