Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

Alteryx R tool- change output path to dynamic folder

nkazi01
7 - Meteor

Hi, I am new to Alteryx and trying to figure things out. Sorry in advance if this has been already answered before, but I could not find a solution for my specific situation. 

I am using R tool to create a new folder everyday with the current date. Example, today's folder would be created as '2022-07-14'. After that, I am using some excel files as inputs and then outputting csv files. My issue now is that I want to output these csv files in the new folder I just created, but I am not sure how to do it.

A new folder will be created everyday and the excel files will go in that folder everyday for that date. 

Code below

 

day_1 <- Sys.Date()
day_1

 

folderstring <- paste('[insert directory path here]',day_1,sep = "")

folder <- folderstring

 

#create new folder with current date
if (file.exists(folder)) {
cat("The folder already exists")
} else {
dir.create(folder)
}

folder  ## example output --> 2022-07-14

 

 

df <- read.Alteryx("#1",mode="data.frame")
write.Alteryx(df,1) ## I want to output this to [path]/2022-07-14

2 REPLIES 2
mceleavey
17 - Castor
17 - Castor

Hi @nkazi01 ,

 

you can actually create a new folder each day using the Render" tool, no need to do that in R, but given you have already done that, let's skip to how you can output to those folders.

First, create a new field "Filepath" in a formula tool and configure it to represent the filepath:

 

mceleavey_0-1657818404491.png

Notice the date part will be dynamically created each day which will correspond to the folder you created in R.

This gives the filepath as:

E:\Dropbox\Bulien\Alteryx\Datasets\2022-07-14\New_Filename.csv

 

In your Output Data tool, take the filepath from this new field:

mceleavey_1-1657818530486.png

 

This will now overwrite the entire filepath each time to the new folder.

 

I hope this helps,

 

M.

 



Bulien

nkazi01
7 - Meteor

Hi @mceleavey,

 

This helps a lot. I am able to create the files in the desired path and folder. 

However, now that I have a new field in each file with the path, how do I get rid of that field after? I do not want the field with the path in my final output of the excel files. 

 

EDIT: Nevermind, I figured it out. I just had to uncheck the "Keep field in Output" box in the output tool. The Filepath field is not showing anymore in my out files. 

 

Thank you very much for your prompt reply and help. 

Labels