Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Loop and compare multiple xml files

ArunAnnaldas
6 - Meteoroid

Hi All, 

 

I have a project where i need to compare xml files between 2 directories. Below is the pattern of file names in each directory. 

 

Directory 1

- sample1.xml

- sample2.xml

- sample3.xml

 

Directory 2

- sample1.xml

- sample2.xml

- sample3.xml

 

I need to compare the data in respective file name. Could you please assist in this regard? After reading through the community questions, I assume batch macro would be the right way to go ahead. Could you share any leads to quickly do this task? 

 

Thank You!

9 REPLIES 9
TheOC
15 - Aurora
15 - Aurora

hey @ArunAnnaldas 

It sounds like a batch/iterative macro would be the one for this.

Just to help me build something for you, how are you 'comparing' the xml files?

Cheers,
TheOC


Bulien
ArunAnnaldas
6 - Meteoroid

Thank You for the prompt response!

 

Below is the approach I have used:

 

1. Read a xml file (say Sample1.xml) from Directory 1 using input data tool. Use Select Tool and select the tags required for comparison.

2. In Parallel, read another xml file (say Sample1.xml) from Directory 2 using input data tool. Perform Data Massage using XML Parser (since it has cascaded/child nodes). Use Select tool and select the tags required for comparison.

3. Use a Join tool to perform comparison. 

4. Use Browse tool to view the compared output (Left/Join/Right)

 

Using above approach, I am able to compare 2 xmls. But i am not sure how to iterate for all other files based on file names.

 

Hope this helps!

 

Regards,

Arun Annaldas

ArunAnnaldas
6 - Meteoroid

Hi 

 

Did you get a chance to look into the problem statement? Please let me know if more information is needed. 

 

Any help is highly appreciated.

 

Regards,

Arun 

TheOC
15 - Aurora
15 - Aurora

hey @ArunAnnaldas 

Sorry for not getting back to you!

Are you able to provide your workflow for comparing them currently? And i'll have a look at bringing the other files in for a macro.


Cheers,
TheOC


Bulien
ArunAnnaldas
6 - Meteoroid

Hi TheOC

 

Thank You for your assistance. 

 

I am able to compare 2 XML files from two directories. However, I am not sure how to loop through all files  and perform a comparison (based on the file name). 

 

Regards,

Arun Annaldas

TheOC
15 - Aurora
15 - Aurora

hey @ArunAnnaldas 

Its hard to build for you without the workflow exactly, so ill try to guide you through the steps to create this.

Before you do, i suggest checking over this:
https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Getting-Started-with-Batch-Macros/t...

What i imagine you will nbeed to do, is have a directory tool on the two folders you are trying to compare:

TheOC_0-1620913451433.png


Here you can also specify a file specification, so only *.XML files will all be picked up.


You can then create a batch macro, that will take these two inputs, and use a dynamic input file to input them into the workstream. As we are comparing these one at a time, we will use the 'filename' of the file, to filter on, to make sure its a different row being processed each time with the control parameter.

 

Then, do what processing you need to do, and output it as a macro output.

I have attached the framework of this, with containers explaining what each part is doing. Make sure to right click the macro and open it, to see what it is doing. This will not work as default, it will require tinkering, but should get you most the way there.

Sorry i cant take it much further, its impossible to know exactly what you're doing without the workflow or files, but this should be close for you to be able to finish. I also suggest looking at this:
https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Getting-Started-with-Batch-Macros/t...


Cheers,
TheOC


Bulien
ArunAnnaldas
6 - Meteoroid

Sure 

Will go through the suggestion mentioned. 

 

Thank You,

Arun

TheOC
15 - Aurora
15 - Aurora

no problem!

If it helps feel free to mark as a solution to help people in the future, and give me a shout if you run into any roadblocks!

Cheers,
TheOC


Bulien
dougperez
12 - Quasar

Ok, have you tried to put wildcards and output the filenames on the input? 
Then you do the join with the filenames to work on each file.

If you can, post an example of the XMLs, I can do one workflow to help you.

Labels