Weekly Challenge

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

We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!

Submit Feedback
We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.

Challenge #7: Download Data and Parse JSON

Highlighted
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.

Highlighted
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.

Highlighted
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.
Highlighted
Ravenclaw

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

Tara McCoy
Highlighted
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

Highlighted
Alteryx Partner

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.

Highlighted
Alteryx Certified Partner

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






Highlighted
16 - Nebula
16 - Nebula

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.


Highlighted
Alteryx
Alteryx

Solution attached.

 

I really liked @GeneR use of the Dynamic Rename!

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Happy Sunday

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.