Alteryx Designer Desktop Discussions

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

Adding a date column to multiple files

jacwood
6 - Meteoroid

I have multiple files that I need to add a date column to without combining all the files into one. I have attached the workflow I created below. 

4 REPLIES 4
AngelosPachis
16 - Nebula

Hi @jacwood ,

 

I think the best way to achieve this is by using a batch macro. Outside your batch macro, you will have a directory tool like you have in the workflow you have already created. Then that directory tool will feed into the control parameter of a batch macro.

 

Inside your batch macro you will have an input tool, a formula tool that will create the date column, a block until done tool for safe measures and then finally an output tool. Then you will have to connect your control parameter to the input and output tools and replace the path that the file is read from/wrote to.

 

As a heads up, this method will overwrite the existing files. If you want to create new ones, then you can tweak the output file path to be different than that fed by the control parameter.

 

Hope that helps,

 

Angelos

ArtApa
Alteryx
Alteryx

Hi @jacwood - The attached workflow does it for you with following assumptions:

 

1) Excel files are in .\XLSX

2) All Excel files are of the same schema

3) All Sheets are "Sheet1"

 

ArtApa_0-1625120230315.png

 

jacwood
6 - Meteoroid

Hi @AngelosPachis,

 

The instructions you gave were very helpful. However I am still having some issues saving the files out individually after the column has been added. It is currently adding the column to all the files and saving it as one big file. I attached the macro I built below as well as the workflow. 

AngelosPachis
16 - Nebula

Hi @jacwood ,

 

I'm glad that you found it useful. I think you are close but maybe you have to tweak your batch macro a tiny bit.

 

Try bringing your output data tool inside your batch macro as shown below, and connect the control parameter with the output tool. Then, configure the action tool so it replaces the file name (no need to check the checkbox at the bottom left, if you don't and you have File selected, the control parameter will replace the whole string and not a part of it)

 

AngelosPachis_0-1625162479145.png

 

You can see an error question mark appearing n the screenshot but that's because I don't have access to the filepath you are writing the output, it should go away for you.

 

When you are done configuring the macro, save it and try running your main workflow (your batch macro will not have an output anchor, but you don't need one

AngelosPachis_1-1625162684964.png

 

Let me know if that worked for you, I've attached the batch macro file over as well to my post for you to find.

 

Labels