We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!

Alteryx Designer Discussions

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

Workflow with two directories that run through a batch macro

gwiz
8 - Asteroid

I am trying to run a workflow that will run one directory of 4 text files and also run a directory of 4 excel files. The underlying macro reads each text file and excel file, does some cleansing, joins the two based on an ID. The workflow will run the directories of each of the two types of files and then the final output should be an excel file with separate tabs for each excel and txt file combination (i.e. 4 tabs). But I am having trouble getting this all to work! As can be seen below are the text files directories and excel files directories. The macro has two input tools in it but for some reason not two inputs when you go to insert the macro into this workflow...So what I try to do is do a text to columns to take off the .txt and .xlsx extensions. Because the text and excel files are named the same except for those extensions and then I join them based on this same name (i.e File1.txt and File1.excel, File2.txt and File2.xlsx --> both get split to say File 1, File 2, etc in a column per each text to columns tool). Thus I join them on this newfilename field per each side. Then I try to run the macro after that (as I am trying to compensate for the fact that there aren't just two inputs dierectly into the batch macro). I hope that I am explaining this well enough. Thanks for the help!

twodirectoriespic.png

5 REPLIES 5
jamielaird
14 - Magnetar

Hi @gwiz 

 

It's tough to diagnose the exact issue without seeing your workflow but from what I can see in the screenshot the only input to your macro is the Control Parameter (upside down question mark).

 

Within the macro, have you made sure that you are using Macro inputs?

 

Screenshot 2019-05-05 at 16.10.11.png

 

If you have regular input tools (green icons) you can right click on them to convert them to macro inputs.

 

-----
If I've solved your problem please consider marking this solution as accepted. Thank you!

 

gwiz
8 - Asteroid

@jamielaird thank you for starting to get me on the right track. 

Okay I made two macro inputs in the macro. and I also made some dummy data and have attached the macro and workflow because I think it will be easier for you to help further that way.

Macro:

read in txt file and excel file, cleanse both, and join on username

 

Workflow:

do this for multiple txt and xlsx files and the output should be an excel file with each sheet being named by the file name (i.e. Hijklmnop_dc3ep.xlsx or Hijklmnop_dc3ep.txt --> Hijklmnop_dc3ep). take filename from either source as they are named the same except for the extension file type.

 

Right now I am getting an error

 

topost.pngtopost2.png

 

Also see the macro and workflow attached:

danilang
18 - Pollux
18 - Pollux

Hi @gwiz 

 

It's hard to tell without some actual data files, but according to your error message, one of your 2 input streams is missing a field called username.  Any chance you could include a sample excel and matching .txt file

 

Dan

gwiz
8 - Asteroid

Does my attachment of the package include the inputs? Let me know if not and I will upload those files

danilang
18 - Pollux
18 - Pollux

hi @gwiz 

 

Your package doesn't contain the input files

 

Dan

Labels