Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Parsing multiple json files in a directory to a single output

synergy825
8 - Asteroid

Hello,

 

I am fairly new to Alteryx.  Is there a way to combine multiple json files to be parsed into a single output like a CSV file or hyper file for Tableau?

 

In the attached workflow, the top line is running correctly for a single json file.  I tried replicating it in so that it is looking at a directory instead on the second line where I will be storing multiple json files.  However, I'm not quite sure how to complete the flow.  Any help would be greatly appreciated!

5 REPLIES 5
Felipe_Ribeir0
16 - Nebula

Hi @synergy825 

 

Try to replace the file by files\*.json. Be sure to keep the same delimiter and the rest of the config.

 

Felipe_Ribeir0_0-1675374287701.png

 

binuacs
21 - Polaris

@synergy825 one way of doing this with the batch macro

 

binuacs_0-1675374391796.png

 

synergy825
8 - Asteroid

Thank you @binuacs and @Felipe_Ribeir0 !

BS_THE_ANALYST
14 - Magnetar
14 - Magnetar

@synergy825 Great idea using the directory tool. You can certainly continue with your thought process. You just need to tweak a few things to get it up and running. The directory tool will provide you with data about your files, depending on where you are pointing it. You want to point the directory to the folder that contains the multiple JSON files you mentioned. This tool will go into that folder, and find the files and information related to those files for you. This is useful, as we can use the FullPath information that the directory tool will give us. Therefore, we can pull those files into our Alteryx workflow as we have their FullPaths. 

One caveat to using the directory tool. BE CAREFUL. If you are pointing it to a folder which has loads of .json files, it can potentially pick all of those up. I would recommend creating a new folder and moving the .json files into that folder (for simplicity sake). 

 

We use *.json in the File Specification. This means, pick up anything in this folder which is the file type .json ..

BS_THE_ANALYST_0-1675374973871.png

I created a few copies of the JSON file you gave for demo purposes. See below, I have 3 json files in the folder I pointed it to:

BS_THE_ANALYST_2-1675375069873.png

 

Now we want to bring in each of these files, one after the other. Essentially completing the workflow for one, bringing in the next file, completing the workflow for that one, and then appending it to the bottom. This process can be completed by using a Batch macro i.e. doing it in batches. 

I created a batch macro for you, leveraging the workflow you gave. In here, it basically says we will only process one of those files from the directory at a time.

BS_THE_ANALYST_3-1675376891572.png

This is the final product below. Make sure you change the field highlighted in yellow (top left). On the control parameter configuration to FullPath. Just as a check, we can see 114846 records. Which is your output from your previous one tripled. Hopefully this helps! Definitely have a look into batch macros. 

 

BS_THE_ANALYST_4-1675377039551.png

 



 

 

All the best,
BS

LinkedIN

Bulien
synergy825
8 - Asteroid

Thank you @BS_THE_ANALYST !  for the detailed explanation.  This was very helpful!

Labels