Hi,
Thanks in Advance!
I'm new to Alteryx and I'm trying to load multiple files having different schema to multiple SQL tables using batch macro & dynamic input. But only 1 file is read and other files are skipped.
Example : I have 2 files "File1" & "File2" and these 2 files should be loaded to 2 different SQL tables when i give the folder path to directory tool.
File 1:
SNO | Name | Designation |
1 | Mark | Manager |
2 | Tim | Senior |
3 | Jon | Staff |
File 2:
SNO | Name | Department | Pay |
1 | Mark1 | ABC | XX |
2 | Tim1 | XYZ | XY |
3 | Jhon1 | ADF | XZ |
Method i used is :
Can anyone help in getting this done. With an example.
Thanks!
Solved! Go to Solution.
hi @Rajinikanth
If you use dynamic input for this , you are always going to have problems with the fields
You need to receive in the macro the file name, without using the dynamic input, in the same macro you can add a insert in to the table, sending the name dynamically
i hope it helps
Let me know if you have more questions
Thank you !
I now removed dynamic input tool and now the different schema issue is not shown, but when i load data to SQL tables. Both the tables have columns from both the files. But it the table should ideally have column names that are present in the source input file.
Example : Output table has fields as below,
Table1 :
SNO | Name | Designation | Department | Pay |
Table2:
SNO | Name | Designation | Department | Pay |
Note : Fields names related to other file is populated will nulls.
But the output table should have fields exactly as the source file.
Can you please help on this.
Thanks!
Hi @Rajinikanth
You send the files with the same names, I guess some are different.
I this a batch macro? Do you have configured in the interfaz designer this options?
try first configuring this. If doesnt work you can do the following:
So I will send to the macro the list of fields, maybe separated with coma.
Inside the macro I will separe it , compare it with the ones that are in the file (maybe with transpose or field info) and assingn it with dynamic rename or using dynamic select
Just some ideas hehe, perhaps it would need less steps
Thank you Soo much for the quick response. I haven't selected the option "output fields change based on input configuration". But now I updated the batch macro configuration below is the screenshot for same. But still the output is same. Field names are coming form both the files.
Can u please share me a sample workflow on how to get only the source file fields in the output table.
Thanks!
Please find attached a sample workflow to achieve what you described. This process creates yxdb files in the output folder as outputs. This can always be replaced with a database write within the macro.
Let me know if this helps.
Best,
Jagdeesh
I Changed the Macro WF by adding "Output tool" directly in macro instead of Macro out and Called this Macro in the Main WF which solved the issue.
Thanks!