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.

Input Batch Macro - AKA the Extra Dynamic, Dynamic Input

JoeS
Alteryx
Alteryx

It’s about time I release my “Input Batch” macro, so here we go......

 Meme.jpg

 

 

For those of you familiar with the Dynamic Input, you will know how much of a life saver it can be, but from time to time, you may be frustrated by the need for the file formats to be the same. Both the type of file (Excel, CSV, TXT etc) and also schema (field types, size and number/name of columns).

This can often cause a few issues, as Alteryx reads in the template and will then use that as the type of file, and then the first file it reads in dictates the schema.

 

Well, if you want the ability to read in many different types and many different schemas at once, you are in luck!

 

I have built a macro (with a sub-macro) that will be able to read in: ".yxdb",".cydb",".sz",".avro",".csv",".dbf",".mdb",".xls",".xlsx",".xlsm",".sas7bdat",".sav",".sqlite",".xml”

 

The input required is the full path with extension. This enables you to use the directory tool, apply any logic to filter the list (AKA get todays files) and then input that in.

 

After that it will go through all the files and read them in. Then using the power of Union it will align all columns named the same, any extra columns get added to the end.

 

There is also some extra stuff when it comes to Excel, it will actually loop through all the sheets and read them in one by one.

 

Hopefully some of you will find this useful.

 

If you provide it file types that it is not able to read, it will through a warning.

 

Feel free to add comments about future enhancements and I’ll look to see if I can add them in.

 

Attached is a zip file (.7z), with the installer (.yxi) and some sample data with a sample workflow.

22 REPLIES 22
bchen1
6 - Meteoroid

Thank you so much for this macro. Quick questions

  • Is it possible to configure it so I can output for Rows 10 and beyond
  • How would I output just the filename? Right now when I batch the files, the full path is being pulled and I just want the filename

Thanks for the assistance.

JoeS
Alteryx
Alteryx

@bchen1 wrote:

Thank you so much for this macro. Quick questions

  • Is it possible to configure it so I can output for Rows 10 and beyond
  • How would I output just the filename? Right now when I batch the files, the full path is being pulled and I just want the filename

Thanks for the assistance.


You're welcome, I am glad you are finding it useful.

 

To update it to only output from 10 rows and beyond, you'd need to open up the macro and modify the input tools within. I'd then recommend saving this as your bespoke version as my guess is it won't always be from row 10 in all uses?

 

For the second part you could modify the input tool as well, but there is a nice easy function in Alteryx to extract the file name from a file path:

 

FileGetFileName([FileName])

 

That should then give you what you need without changing the macro itself.

 

Thanks

Joe

monsieursnow
5 - Atom

Hi @JoeS

 

Thanks for sharing this macro. You don't know how many times this saved me.

I just wanted to share some potential bugs which i couldn't resolve:

1) unable to work on xlsm workbooks

2) if worksheet name has a space at the end, then it throws out an error

 

I'd wish i know how to fix it, but just putting it here for tracking or once i find time to "attempt"
 to fix it!

 

Edit:
Replying to myself - i found a solution for the above problems.
i'm not sure if this will fix xls or xlsb problem, but the sheet name having a trailing space was a problem for me.

 

Hadn't had time to incorporate this back into your original workflow, but below formula should fix the trailing space problem.

It's currently reading the Sheet Names as-is without the "$", which might cause problem if there is a trailing space like my case.

(Somehow it trimmed it and couldn't find that particular worksheet)

 

Formula:

</quote>

left([FileName], FindString([FileName],"|||")+3)
+'`'+
[Sheet Names]
+'$`'

</unquote>

Labels