Alteryx Designer Desktop Discussions

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

Passing Multiple Values into Zip File Input Tool

BradFolger
7 - Meteor

I did a quick search but couldn't find anything on this; pardon if it's a duplicate.

 

I'm trying to dynamically feed values into an Input tool. I've done this with a batch macro when looping through several files in a directory, but that's only been for .xls or .csv files, where the connection string is relatively simple. In my current case, I need to pass in the name of .zip files -- which is easy enough at the top level (filename, full path), but for .zips, an additional attribute is required on the input side -- namely, the name of the file to be extracted from within the .zip that will serve as the basis for the input.

 

Is there a way to pass both the full path for the filename to the macro, but also the file within the .zip that needs to be extracted from the .zip and serve as the basis for the input? From what I can see, only a single value can be "updated" on a single Input tool using an Action in the Macro -- but I'm assuming there's a way to do this?

5 REPLIES 5
Dynamomo
11 - Bolide

@BradFolger

It works pretty much the same way as your other batch macro except that when you feed in the filename, it will need to look like this:

C:\temp\file3.zip|||file3.csv

The zipfile is listed and then some pipes are added to delimit the file within it.

If you want to see this for yourself, just bring in a zipfile with a file in it using the regular Input Data tool.  Then add a control parameter and an action tool above this.  Now click on the action tool and select Update Value (Default) as the action type.  When you do this, the file - value will be visible and you can see for yourself how the path looks when Alteryx reads it in.

Hope this makes sense.  If not, I can send a macro and workflow but wanted to step you through it so you could see for yourself.

 

BradFolger
7 - Meteor

Perfect! That worked like a charm. Thanks Dynamomo.

 

For others, all I basically did was took the Directory tool's FullPath value, and used a Formula tool append the compressed file's name to the end. In my case:

 

Original FullPath:

\\uncpath\somedirectory\somesubdirectory\incoming\ABCFile Feb 15 2018 15-47-44 PM 58.zip

 

Replace function in Formula tool (overwriting the original FullPath):

[FullPath]+"|||"+Replace([FileName],".zip",".csv")

 

FullPath becomes:

\\uncpath\somedirectory\somesubdirectory\incoming\ABCFile Feb 15 2018 15-47-44 PM 58.zip|||ABCFile Feb 15 2018 15-47-44 PM 58.csv

 

This is passed into the Batch macro control parameter, and an Action updates the .zip file Input within the macro.

 

wottel
8 - Asteroid

I'm having a similar issue and what was posted makes sense. I'm running into a problem because the zip contains sub folders. I'm using a formula to update the zip filename and then the subfolder/json file that I need to read

 

My formula appears to be updating the json file path with a forward slash, which matches the format when using a standard input tool. forwardslash.JPG

 

But after running the workflow and getting warnings, it shows the forward slash has changed to a backslash, which I think is causing the json files not to be read correctly

backslash.JPG

 Any suggestions??

 

And just to confirm the subfolder is the issue, I moved the json for 2 zips out of the subfolder, updated my formula,  and the dynamic input worked.

 

Test.JPG

 

 

 

 

 

indranilg
5 - Atom
I've had a similar issue while trying to extract a csv within a subfolder using a dynamic input as its a daily generated file.
Eg: 20180813_Sample.zip > Sample > Data.csv

I need to use dynamic input to cater to the datestamp, but am unable to extract the csv from the Sample folder, after unzipping.
baijuspatel
5 - Atom

@BradFolger - Would it be possible to share your Macro and/or Workflow files? I'd love to reuse them. I am new to Alteryx and in need of looping through a directory which has zip text files and converting them to a csv one by one. hence i think this would be very useful. thanks in advance. 

Labels