Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #7: Download Data and Parse JSON

GeneR
Alteryx Alumni (Retired)

Welcome to 2016 we hope you are enjoying these challenges. The link to the solution for last challenge #6 is here. For the seventh challenge let’s look at downloading data with an API and parsing that data from JSON into a usable format.

The data we will use comes from Quandl. The Quandl site offers access to several million financial, economic and social datasets. Data is indexed from multiple sources allowing users to find and download in various formats. All Quandl's data are accessible via an API.

 

For this example the response from these APIs is JSON. Our user is trying to get aggregated Annual Outbound Tourism Statistics for the US dating back to 1995. The Text Input contains the URL for the API request. Your goal is to parse the response.

 

Hint: After parsing the JSON, you will need to further identify the patterns within the data to effectively stage into a table for analytics.

Note: The data in the API is subject to change. When trying to match the output, the effort should be focused on achieving an identically structured dataset. 

 

We have listed this as an advanced challenge since configuring the download tool and parsing functions are more advanced topics. We are looking forward to hearing your feedback.

 

UPDATE 1/11/2016: the solution to this exercise can be found below.

UPDATE 4/10/2019: Previous API link expired. Exercise updated to new API.

martinbosak
6 - Meteoroid

This one is very nice! And i think relatively frequently used example. Great for playing with data from internet and so many options how to get this done. In the end i used a lot of tools here.

dataMack
12 - Quasar
Great exercise here. I'm finding the need to parse JSON data more and more. It'll be interesting to see the variety of ways people choose to wrangle the data after the initial JSON parse- I can think of a few different options.
TaraM
Alteryx Alumni (Retired)

The Exercise has been updated with the solution. Thanks for playing along.

Tara McCoy
CaptCube
6 - Meteoroid

This was a tricky one. On first connetion I got an error message in the download field and thought the URL had gone bad. Manually checked it in the browser and saw that it was actually part of the header of the dataset. Sneaky

Smiley Wink

TomWelgemoed
12 - Quasar

Thank you for this great exercise. We're using this as part of our certification practise.

 

Just a pointer that the output data appears to now have moved/changed (so the challenge output is now out of date), which is perhaps understandable if pulling from an API.

mceleavey
17 - Castor
17 - Castor

Ok, not sure if this is the best way, but hey, it's Alteryx!

I used the Dynamic Rename tool, but I sure this could be sorted and joined in a different way which may be more efficient. Anyway:

 

Spoiler
I began by simply feeding the URL into the download tool and parsing the JSON file using the JSON Parse tool:

1. Download and parse JSON.PNG

I then split the resulting data into two streams based on filters, first to isolate the Column Headers:

2. Column Header Stream.PNG
and then the data:

3. Data Stream.PNG
The data stream was then pivoted so the Field Numbers are the headers of the columns.

I then used the Dynamic Rename tool to join the data but replacing the numbered headerfs with the header values from the Columns stream:

4. Pivot Data and dynamically rename.PNG

I then simply sorted by row and dropped the unwanted columns:

5. Sort and drop unwanted columns.PNG








Bulien

SeanAdams
17 - Castor
17 - Castor

Very similar solution to the one provided except....

Spoiler
left the data in a transposed state, and then used a join to replace the field names (similar to what @mceleavey mentioned)
However - the provided solution does a better job of ordering the fields, so that it doesn't have to be done manually using a select tool.


KatieA
Alteryx Alumni (Retired)

Solution attached.

 

I really liked @GeneR use of the Dynamic Rename!

MarqueeCrew
20 - Arcturus
20 - Arcturus

Happy Sunday

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.