Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

How to exclude text files when importing via macro

RZTidwell
5 - Atom

Hi all,

 

I have a workflow that uses a macro to import delimited .txt files from a certain directory. When I receive these files, they are all named similarly, but about half of them are structured differently and aren't relevant to my workflow. (See examples, attached.)

 

Is there a way to exclude these extraneous files based on the data contained within? For example, the needed files all have "Line items" as the first row, while the other files don't; could I maybe use that somehow?

 

I've been pulling my hair out on this one, and I didn't have much to start with, so any help would be appreciated! 🙂

 

Russ

Workflow.pngMacro.png

 

 

4 REPLIES 4
fmvizcaino
17 - Castor
17 - Castor

Hi @RZTidwell ,

 

I'm attaching an example showing how to use the command line to erase unwanted files.

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Tool-Mastery-Run-Command/ta-p/31548

https://www.theinformationlab.co.uk/2017/08/10/delete-files-alteryx-cleaning-computer-part-1/

 

Let me know if this works for you.

Best,

Fernando Vizcaino

danilang
19 - Altair
19 - Altair

Hi @RZTidwell 

 

Implement this logic in your macro.

 

danilang_0-1586440449790.png

Use a Sample tool to select the first row of each file.  Filter for the ones that start with "Line items".  Join back on Filename.  This will have the effect of filtering out all the rows from the files that don't have "Line items" as the first line

 

Dan

 

RZTidwell
5 - Atom

Thanks Dan! This does what I needed.

 

Russ

RZTidwell
5 - Atom

Thanks Fernando. I don't necessarily need to delete the extra files, but this just opened up some new possibilities that I hadn't considered before.

Labels
Top Solution Authors