Exporting Glowscript data

257 views
Skip to first unread message

dbor...@willamette.edu

unread,
Aug 13, 2021, 7:10:40 PM8/13/21
to Glowscript Users
One interesting thing that I discovered today is that (while a little clunky and moot if you are using installed vPython) it IS possible to export data from a Glowscript simulation to a text file, which you could then open in Excel or some other software package for further analysis (e.g., curve fitting) or for making pretty pictures for a publication or report.

The way to do this is to have Glowscript print comma separated data to the console and then clicking on the console and hitting Ctrl+A once the simulation stops running to select all the data. This can then be pasted into a blank text file in Notepad or another text editor and saved with a csv extension. At that point, Excel will be able to open it.

So e.g., if I put a line like 

print(t,",", cart.pos.x)

at the end of the while loop while doing a simulation of the position of a dynamics cart on a track and followed the procedure above, I would be able to get a table of time and the cart's x position.

Bruce Sherwood

unread,
Aug 13, 2021, 7:39:37 PM8/13/21
to Glowscript Users
Yes, this has always been possible. But there should also be a "download" function to make this easier. I mistakenly thought it wasn't possible to write from the browser to your local drive, but that's not correct; it's just that the browser can't write anywhere except for your Download folder.

Bruce
Reply all
Reply to author
Forward
0 new messages