In Origin 2019b, we introduced a new concept called Data Connector. Adding a Data Connector to a worksheet allows you to connect the worksheet to either a file on disk, a web file or tables in a webpage. Depending on the type of Data Connector, you can then select what part of the data to import into your worksheet.
A workbook can have multiple sheets, each with a different data source and data selection. But in a given workbook, all data connectors have to be of the same type.
Data Connectors are available for CSV, JSON, HTML, and Origin Project files. In this blog we will first show a simple example on get a table from a web page, then show a more complex example to connect to a public domain JSON web file.
Connect to a table in a web page
Suppose you want to import the chemical element table in the wiki page:
https://en.wikipedia.org/wiki/World_population
you simply start with a new workbook/worksheet in Origin, select from menu Data: Connect to Web….
Enter the web address in the popped-up dialog. In the next page, identify the table “10 most densely populated countries” , add it to the bottom panel and click OK to import:
Connect to a web JSON file
Next we will show a more sophisticated example to connect a worksheet with a web JSON file and update the data in the worksheet by making change to web address. To initiate the connection, again you start with a new workbook/worksheet, and then select from menu Data: Connect to Web…. In the next page, identify the table in the list to import. You can also launch the tool from the App panel. Click JSON Connector app in Connectors tab.
In the dialog, enter the web address:
https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2019-01-21&endtime=2019-01-22
which provides earthquake data for the specified time period of 2019-01-21 to 2019-01-22.
Next, we see a dialog where we can make a selection from the data structure. We select node JSON and then check the Nested Arrays as Columns check box. Click OK.
Now, the data is imported into the sheet. We can then process the data to create a nice Origin graph. In the image below, the data was plotted as a scatter plot where the color of the symbol is mapped to the magnitude of the earth quake. The Google Map App was then used to place a map behind the data.
When you save an Origin project that has a Data Connector, Origin removes the imported data, and only keeps analysis results generated from the data. This allows for the project size to be small, and you simply re-import the data when needed.
After saving and re-opening the project, the worksheet and the graph will be empty. Note that we had not performed any analysis on the data. If any analysis is performed, the analysis results will not be cleared, and will still be available when the project is opened later.
Now let us change the date range. To do this, we need to change the data source, as the date is embedded in the URL. Click on the Data Connector icon again, and select Data Source… . and enter the new URL.
https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2019-01-22&endtime=2019-01-23
The data gets updated and also the graph.
You can download the Origin project with the connection and graph already set up. Note that Origin version 2019b or higher is required. In the project, you can try the above steps such as changing the data source to change the time frame.
thanks for shairing this post