Merging Data Files Using the API

Merging Data Files Using the API

This blog post shows you how to use Displayr's API to merge two data files, and import the revised data file into a Displayr document.

Step 1: Do everything in Getting Started with the Displayr API

Once you have done this, open up the document and review the sample size on the first page, which should be 725, as shown below.

Step 2: Obtain the Document secret

To modify a document using the API we need to know its Document secret. This is found by following these steps:

  1. Go to the document’s settings page (if in the document, click on the cog at the top right of the screen and press Document Settings)
  2. Expand out the Properties section.
  3. The document secret is located in the bottom-right corner.

Step 3: Download the file

  1. Click here to download the zip file
  2. Double-click on it to open it
  3. Save its contents somewhere on your computer or network

The zip file contains:

  • A data file called PhoneExtra.sav which contains data to be merged into the data in the existing Displayr document.
  • A file called which contains a Python script for merging

Step 4: Edit and run the

  1. Open the file in a text editor
  2. On line 26, replace insert-document-secret with the document secret obtained earlier
  3. On line 29 replace current-file-name with the name of the file used in the document; in this example, it’s called Phone.sav
  4. On line 32 replace extra-data-file-name with the name of the file containing the additional data; in this example, it’s called ExtraPhone.sav
  5. Save the file
  6. Run the script, as described in Getting Started with the Displayr API

You should now see that an extra four cases have been added to the sample size at the bottom of the chart on the first page.

About Tim Bock

Tim Bock is the founder of Displayr. Tim is a data scientist, who has consulted, published academic papers, and won awards, for problems/techniques as diverse as neural networks, mixture models, data fusion, market segmentation, IPO pricing, small sample research, and data visualization. He has conducted data science projects for numerous companies, including Pfizer, Coca Cola, ACNielsen, KFC, Weight Watchers, Unilever, and Nestle. He is also the founder of Q, a data science product designed for survey research, which is used by all the world’s seven largest market research consultancies. He studied econometrics, maths, and marketing, and has a University Medal and PhD from the University of New South Wales (Australia’s leading research university), where he was an adjunct member of staff for 15 years.