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

Alteryx designer Discussions

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

Read in a file AFTER it's been produced by R script within the same workflow?

Asteroid

I'm trying to make a workflow that does the following: 1) Run R Script to produce spreadsheet 2) Do stuff with spreadsheet

 

Since the Excel spreadsheet (Input Data) is coming from the R script, how can I put a dependency or hold to prevent Alteryx from trying to read the spreadsheet while it's being produced? It takes the R script about 2 minutes to produce the file and I need to either have a delay or have Alteryx "know" when the file's been produced. 

Alteryx Certified Partner
Alteryx Certified Partner

Will the Excel file not exist before this script is ran, or does the script only update it?

 

if the file does not exist, you could build a Iterative macro to loop while the file is being created. To check if a file exists, the function "FileExists([filepath])" will return a value of "true" if it does. Use this to test if the file exists each loop. Place a Block Until Done tool after this iterative macro and then "Do stuff with spreadsheet" from there.

Alteryx Certified Partner
Alteryx Certified Partner

I believe you have three options.

 

Option a) add an additional line of script that instead of/aswell as writing to an excel file it writes to a dataframe which you can then use the write options that exist within the Alteryx R tool to output that dataframe as a stream from the R tool. This is the easiest approach by far.

Option b) write a dummy variable to a dataframe, then use the write options to pass this out of the other side of the R tool. You can then use a formula tool to give the path for the incoming file. Then use the dynamic input tool to input the file from that path. Nothing will proccess down stream until the R tool has completed processing. 


I've provided an example of this option.

Option c) try and do what you have done in the R tool with the standard Alteryx toolkit.

Alteryx Certified Partner
Alteryx Certified Partner

Oh, option D, add another line of R code that reads the excel file and then use the write options within the R tool to move this into one of the output streams. This would obviously need to be your last line.

Asteroid

Thanks everyone. I'll be in meetings the rest of the day but will report back a solution or clarifying questions when able to!

Labels