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

Alteryx designer Discussions

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

Capturing the Source File Name from a Macro Input

I would like to configure a macro to write the input file name into a field, capturing the file name from the macro input. I can't rely on the 'Output File Name as Field' option being used, since the file input is outside the scope of the macro. I was hoping there was some sort of function that would parse the source filename from a data stream, but have as yet been unable to find it.

 

Screen shot attached below, for general reference:

Filename_from_macro_input.PNG

 

Thanks,

-Dan

Alteryx
Alteryx

Hi Dan,

 

Is the input file outside the macro changing? If so the input file should automatically update the macro input and change the file name field if you choose the 'Output File Name as Field' option. I have tested this and it seems to work for me. 

 

Alternatively there is the field info tool within the developers tab which produces the source file you referenced below. You could then parse the file name using reg-ex or text to column tool from there. 

 

Best,

 

Jordan Barker

Client Service Representative 

 

Thanks, Jordan. That did it.

 

Since I couldn't guarantee the user would have the file name included in advance, I used the Field Info tool as you suggested. From there, I just had to select transpose the Field Info results, then parse the file name from the path. In order to get it back into the output file, I populated the desired _FileName field with "path", then used the Find and Replace tool to replace the word "path" in the _FileName field with the actual file name, from the reference table.

 

Import_and_Standardize.PNG

Alteryx
Alteryx

Excellent! Good work on the rest of the workflow!

Would you please kindly share the source code for this? I have been wanting to complete a similair task.

This was in the middle of a larger workflow, so beg your pardon if it behaves strangely.

 

All the parts are there, though, and the functionality should be pretty straightforward.

Highlighted
Alteryx Alumni (Retired)

 

Posted in error! 

 

Andy Cooper
Senior Solutions Engineer - EMEA
Alteryx
Asteroid

Hello! 

I have a simple macro that reads a folder that has 20+ .txt files with inconsistent schema. just an additional column in few files. So I have used this macro for a while to get this data in a common table. Now I require the file names for each record to be appended to extract some attribution information. when I try to add the filename feature in input tool set inside the macro, the output just appends the template name that's being pointed out rather than the actual file names. 

 

am trying to make use of your macro not am not able to utilize as am very new when it comes to macros. Can you breakdown your WF or give me push to accomplish my ask? 

 

looking forward. 

Alteryx
Alteryx

Hi @Raghu_s

 

Inside of your macro your input tool and interface designer (View>Interface Designer) need to look like this:

 

part1.PNG

 

This will append the file name to each row in that txt file. Make sure you add a browse tool outside the macro to see all rows of data.

 

Best,

 

Jordan Barker

Labels