community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Load multiple CSV Files (all different schema) into multiple SQL Server tables

Hi,

 

Alteryx newbie here. I am facing an issue while importing multiple CSV files with different schemas to multiple SQL tables. I tried looking for a similar question in the forum but could not find one.

 

My problem:

 

I have 3 CSV Files in a folder

1) Sales.csv (8 columns)

2) Finance.csv (5 Columns)

3) Mapping.csv (3 Columns)

 

I need to create 3 tables in SQL Server.

raw.[sales]

raw.[finance]

raw.[mapping]

 

I know how to load multiple CSV files with same schema into one table.

 

Can anybody please help with this?

 

 

 

Alteryx Certified Partner
Alteryx Certified Partner
Hi!

This can be done really easily by using a batch macro.

Essentially you would use a directory input to identify the files you wanted to write and then pass the file path into the batch macro, which would itself contain just an input tool connected to an output tool.

You would then use a control parameter to overwrite the placeholder data in each.

Once you have given the subject area a research please reach out if you have further questions!

Ben

Hi, Thanks for the response.

 

I tried creating a macro and followed all the steps shown here:

 

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

 

This puts all my files into one table and the extra rows are all NULL.

 

I need to put my csv files in multiple tables. Can you please provide example of Batch Macro I can leverage?

 

Thanks

 

 

Alteryx Certified Partner
Alteryx Certified Partner
Instead of having a macro output inside your batch macro as in this case, you want to put your output data tool inside the macro, this way it will write every time for each batch/file.

You will need to figure out how to amend the table name in the output data tool for each run.

Again, let us know if you need further direction.

Ben
Labels