Append or create new file
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am new to Alteryx and I have created a macro that downloads the data from API and saves it into csv file. However I want to run the workflow each day and append the data in the same file for the whole month and from the next month new file should be generated.My problem is, the Dynamic Input is failing when the file is missing and I want to skip the Dynamic Input and create new file from the extracted data.
Solved! Go to Solution.
- Labels:
- Batch Macro
- Download
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The way I would do this is to load the latest data file and include the filename as a field in the output. You can then filter all rows where the month is not the current month and union the result with your downloaded data. If there are no valid rows, no data will be added. Something like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Also, looking at your workflow. you can remove the block until done tool - it serves no purpose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
This is very good idea but it will not work in my case. In the same folder there are multiple files with different sources and this will take the last created which is not the one that we need. Also, what if there are no files at all and they yet to be created.
Regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
you can try to create the file if it not exist (like below). and put the block until done tool before the dynamic input.
Or you manual create all the month file in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
With the directory tool you can be much more specific than just *.* (everything in the folder).
You can tell it to only load excel files (*.xlsx), or you can limit the results by filename and type, like api_data*.csv
So you can see how you can manipulate the Directory tool to only return the correct file.
It is true that you'll have problem if the file doesn't exist, but this will only be true the 1st time. My suggestion is that you create a file with now data in it.
There are other things you can do like put a certain part of the workflow in a container that you can dynamically disable or enable, or look at something like a detour tool, but this all gets very complicated and that is not necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I have added additional macro within the macro for loading existing files and the issue with the errors has been solved.
