Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Data Output post and replies

Return to the Data Output thread
Login to post to this thread

Data Output - Jun 25, 2012 at 11:35AM
Tom Dooling
2 Posts

How can I write out data from a simulation to another file? It used to be I could copy and paste from a data table, but that does not seem to be possible now. Do I need custom java code to create and write to a file?
Thanks
Tom


Replies to Data Output

Re: Data Output - Jun 25 2012 12:12PM
Francisco Esquembre
136 Posts

Hi.

There are reading model elements, particularly for text files. To WRITE a file, you have to use plain Java.

Attached is an example of such a possible code that opens a text file and writes data to it as it gets generated. Don't forget to close the file before quitting the simulation. Study the code and you will quickly see how it works and be able to adapt it to your needs.

Paco

PS: We have done nothing to the data table that prevents it from copying and pasting. Please send me  (fem@um.es) the example and I will have a close look at it.

Post edited June 25, 2012 at 12:07 PM EST.

Attached File: ejs_WritingToTextFile.zip



Re: Re: Data Output - Jun 25 2012 12:40PM
Tom Dooling
2 Posts

Hi Paco,

Thanks!

Your code was very easy to incorporate into my own simulation.
It works and I'm writing out my data files with no issues.

Thanks again for such a quick response!


Tom Dooling



Re: Re: Re: Data Output - Jun 25 2012 12:44PM
Francisco Esquembre
136 Posts

You are welcome.

Around the world in a few seconds! :-)

Paco



The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics