Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

help with interactions in the files

Fabian_Gamboa
5 - Atom

I’m new user in Alteryx and I used to be programming in R. My question is:

I want to open a specific file from a specific folder, later I need to do a treatment to this file and save it with another name in a specific folder. For example:

Folder: 2018.02/DATA/FILE_10.xlsx

And I need to save it in the same folder but another direction:

Folder: 2018.02/ASSIGNMENT/TREATMENT_10.xlsx

As you can see it’s the same folder but different sub folders inside. Someone could help me? Because I need to do it to 5 years monthly.

 

Thanks.

5 REPLIES 5
CharlieS
17 - Castor
17 - Castor

Hello and welcome to Alteryx-ing!

 

Let's start with some basics, are you comfortable using the Input tool to read Excel files and the Output tool to write Excel files in isolated scenarios? We'll build on those skills to achieve this.

 

Important question: Does the subdirectory "ASSIGNMENT" already exist in the "2018.02" folder? The Output tool in Alteryx can't create directories, so we'd have to address this another way. 

Fabian_Gamboa
5 - Atom

Yes. The subdirectory already exists and it's empty.  I will explain myself in detail:

 

1. I have plenty of directories with "dates", for example 2016.01, 2016.02, 2016.03, which are basically results by period.

 

2. What I need to do is open an specific one which link is "G:/BASES/SAVINGS/RESULTS/2018.02/DATA/FILE_10.txt", what I need to do is changing the period because the same File_10.txt is in every subdirectory (2018.02,2018.03).

 

3. After open the specific file_10.txt I need to do some treatment like changing some fields with formulas and after that I need to save it in the same directory but with another name and in a different subdirectory. "G:/BASES/SAVINGS/RESULTS/2018.02/ASSIGNMENT/ASSIGN_10.txt".

 

I need to do it to 60 files that have the same schema. 

 

 

CharlieS
17 - Castor
17 - Castor

Got it. As long as the the target folder is in the place, A Directory tool and Dynamic Input tool pairing will make this a snap. Here's an overview of how I imagine this happening:

 

- A Directory Input tool will be pointed to "G:/BASES/SAVINGS/RESULTS/" with a target file type of ".txt"

- Use the FullPath field from the Directory tool to feed a Dynamic Input tool. Be sure to configure the Dynamic Input to include the file path as a field (it's a checkbox option). 

- The Dynamic Input will go through the list of files and open them all. This is why you need the file path as a field to keep things organized. Be sure to include that field as a group by option while modifying the contents. 

- Use a Formula tool to update the filepath to the new location with an expression that looks like this Replace([FullPath],"/DATA/FILE_","/ASSIGNMENT/ASSIGN_")

- Configure an Output tool to "Take File/Table Name from Field" and use the file path you have modified to the new location.

 

I'd build an example, but since the folder structure wouldn't package with it, it might not be helpful. Let me know if you have any questions on a particular step in the process.

Fabian_Gamboa
5 - Atom

Thank you.

 

I try it but I don't want to open all the files that have the same name, I want to do it iteratively. Because the process that I need to do is per period.  I will attatch a photo about it Question.png

As you can see at file "CAPA_10.txt" is in every subdirectory that I have:

Directory.png

 

What I need to do is open the specific file "CAPA_10.txt" later make some threatment (lef_join,formulas,uniques,select) After all this process I need to save it as the same name by subdirectory (Assignment_10.txt) but it should be in every period (2018.01,2018.02,2018.03,etc.) like this:

 

G:/BASES/SAVINGS/RESULTS/2018.01/ASSIGNMENT/ASSIGN_10.txt

G:/BASES/SAVINGS/RESULTS/2018.02/ASSIGNMENT/ASSIGN_10.txt

G:/BASES/SAVINGS/RESULTS/2018.03/ASSIGNMENT/ASSIGN_10.txt

G:/BASES/SAVINGS/RESULTS/2018.04/ASSIGNMENT/ASSIGN_10.txt

G:/BASES/SAVINGS/RESULTS/2018.05/ASSIGNMENT/ASSIGN_10.txt

G:/BASES/SAVINGS/RESULTS/2018.06/ASSIGNMENT/ASSIGN_10.txt

 

But neither of them are equal to each other because the process must be iteractive according to the period. 

CharlieS
17 - Castor
17 - Castor

As long as you use the entire file path and not just the file name, everything should stay organized. if you'd like to perform this one file at a time, I suggest building this process into a batch macro that uses the full path as the control parameter. 

Labels