Alteryx Designer Desktop Discussions

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

Reading in multiple csv files with different Field Schema - Batch Macro.

racoon
7 - Meteor

Hi,

I have a list of csv files with different schemas. From these files I only want to import the common headers listed below. The file names also keep changing. The only common word in the filenames are "decom". Is there a macro I can use to import the required fields from these files?

Thanks

Ron

 

4 REPLIES 4
HasanHb
Alteryx
Alteryx

@racoon in terms of bringing multiple csv files, you can use the Input Data tool (under the In/Out tools category), point to one of the files that you want to bring in, then use the * wildcard to replace the variable portion of the file name and keep the common portion.  For example, this could look like this:  *dcom*.csv

 

Once you bring in the .csv files, you can use the Select tool (under the Preparation tools category) to keep only the 14 columns that you want to bring in. 

 

I hope this helps.  Please let me know how it goes. 

tcroberts
12 - Quasar

I'm not aware of a tool that will read in only specific headers of files with different schemas, but you could probably read all the files in then use Dynamic Select to drop all that aren't in that list.

 

@CameronS has written a macro that will allow you to read in a number of files with different schemas, and you may be able to adapt it to your purposes. You can find his explanation here:

 

https://community.alteryx.com/t5/Engine-Works-Blog/The-Ultimate-Alteryx-Holiday-gift-of-2015-Read-Al...

  

The macro itself is located here:

 

https://gallery.alteryx.com/#!app/Read_All_Excel_Files/58dd51b3a18e9e18fca64172

 

Let me know if this seems like it might work, or if you need help with the Dynamic Select configuration

 

 

BenMoss
ACE Emeritus
ACE Emeritus

I tend to recommend using this macro 'batch.yxzp' found in this post:

 

https://community.alteryx.com/t5/Alteryx-Knowledge-Base/CS-Macro-Dev-Reading-in-multiple-files-with-...

 

It reads in files of any type and any schema, given a full file path.

 

So you can use the directory tool to read those paths, and then simply plug it into this macro.

 

Ben

racoon
7 - Meteor

Thanks! This works perfectly.

Labels