Data Files
I'm creating a data file for the program I wrote. Here is the setup. I have an input named subject called by viz.input. Then I say the following in the data file:
Code:
start_time = time.time() Subject is Subject is 1 |
Hi,
You're opening the file for appending. So it is adding the data to the existing data in the file. If you want to create the file from scratch open it using the 'w' flag: Code:
question_data = open('study_data','w') |
Yes, I understand I can use the 'w' flag but what happens when I want to add data to the same data file. I can use the 'w' flag for the first time, but then i'd want to append to the file after that. I tried the 'w' flag and it printed out correctly, but then when I changed it to the 'a' flag, it went back to printing strangely again.
The 'w' flag prints like this: Subject 12 Condition 1 The 'a' flag prints like this: Subject Condition Subject 12 Condition 2 |
Hi,
Then I'm not sure exactly what you want. You can either append the data to the file using the 'a' flag, or you can override the existing data using the 'w' flag. What other option do you need? |
No problem,
I figured out the problem. I had to put those statements in a onkeydown event. Thanks! |
1 Attachment(s)
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. |
Hi,
After you open the file, check if it is empty. If it is then write the headings. Code:
data = open('test.data','a') |
All times are GMT -7. The time now is 09:52 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC