Use Glowscript to download data from a website

90 views
Skip to first unread message

Robert Bernard

unread,
May 14, 2018, 8:59:10 AM5/14/18
to Glowscript Users
Is there a way to use glowscript to download data from https://ssd.jpl.nasa.gov/horizons.cgi or similar sites?
Trying to copy, paste, and reformat the data manually is very time consuming.

BTW, I'm new here, I absolutely love Glowscript.

Bob

Bruce Sherwood

unread,
May 14, 2018, 9:32:40 AM5/14/18
to Glowscript Users
Currently the answer is no. There is in GlowScript VPython the get_library() function that lets you import a JavaScript file, but there isn't a get_data() function. It's not clear what such a function should look like, as data comes in so many different formats. Also, for security reasons, there are severe constraints on what kinds of files can be accessed, from where. It's possible that you might need to use VPython 7 rather than GlowScript VPython, not only due to these structural/security issues but also because full Python provides access to lots of scientific data processing tools.

At vpython.org, in the "Frequently asked questions" section, the question about "Is there a way to capture VPython graphical output as a movie" my own comments explain what I did with a GlowScript VPython program that needed access to data. It might give you some ideas. The basic idea is to change the data file into a JavasScript program file.

Bruce

Robert Bernard

unread,
May 14, 2018, 9:53:47 AM5/14/18
to Glowscript Users
Bruce,
Thanks for the info.  I thought that might be the case, since I've found examples where people have done similar things with VPython.
Also, I really love what you've done with Glowscript, I hadn't coded much in years, but now it seems exciting again.
Bob

Bruce Sherwood

unread,
May 14, 2018, 10:54:17 AM5/14/18
to Glowscript Users
One other suggestion, having looked at the data of interest. Copy from the web page and paste into a GlowScript VPython program, like this:

data = """
The stuff you copied from the data web site
"""

Then do string manipulations to convert the string into numeric data, rather than tediously massaging by hand.

Bruce

Bruce Sherwood

unread,
May 14, 2018, 10:58:51 AM5/14/18
to Glowscript Users
If you want to avoid repeatedly doing the string-to-data transformation, you could convert the data to a string consisting of Python commands, print this string, copy the print output, and paste into your program.

Bruce

Reply all
Reply to author
Forward
0 new messages