Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Append data to file

Bargeton
7 - Meteor

Hello,

 

I have a workflow which compute a table results.

I will execute this workflow daily (or weekly, or monthly).

 

I need to write the new computed results, merging it with the previous ones already written into a file.

It's not just an "append" to do, as the previous execution and the current one, may have overlap results.

 

So basically, I need to

- read the existing results file

- compute the new result (it's independant from reading the previous results).

- merge / join both results tables

  ** On left output of the join, I will have all previous results not in current ones

  ** On right output of the join, I will have all new results

  ** In middle output, it's the duplicated results

- then write left + middle + right to the file (overwritte the file).

 

 

This  is working well... if I already have an existing file.

But at the first execution, it bug as there is no existing file to feed the input/read module.

 

How can I acheive this?

 

Regards,

 

Alex

3 REPLIES 3
David-Carnes
12 - Quasar

@Bargeton 
Ok, here is one way; use a batch macro.

First,  use the Directory tool to see if the file exists.

DavidCarnes_0-1669401646380.png

 

Then let the macro decide which Container to destroy.

DavidCarnes_1-1669401729732.png

 

I've attached the two CSV files for the proof of concept.  Put them  somewhere and play  with  removing and returning the test.csv file.

 

I thought of a   way to do this in the R tool.  If you  want that,  say something in the comments.

David

 



shadrachreddy
5 - Atom

can u share the macro file 

David-Carnes
12 - Quasar

@shadrachreddy !
Just download the New Workflow1.yxzp  and the two CSVs .  Double click  on the yxzp file and you'll get the  files.  Right-click the  macro  in New Workflow1.YXMD and   open it up.

Best,

David

Labels