Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How To Output a Zip File using Alteryx

brianvtran
7 - Meteor

Does anyone know how to compress a file using Alteryx? I am currently writing them as .csv but I was hoping to add an additional step to compress the file as well. 

 

I tried looking through the community and there have been suggestions of using a batch file through Run Command but I keep getting an error 1 so there must be something wrong with the batch file I'm creating. 

 

The batch file I have been attempting to create looks like this: 

 

"C:\Program Files\7-Zip"

7z a -tzip "Folder to store zip file" "folder to retrieve file to zip" 

 

this is my first time writing a batch file, so I honestly don't even know if I'm formatting it correctly. 

 

It's my first time using Run Command as well so I am a bit confused about the way to read the configuration options especially with the Write Source option. Am I supposed to have Write Source output it as a .csv file within Run Command and then will Run External Program with my own batch file zip the csv file? Do I do anything to the Read Results window? I was trying to look for saving it as a zip file within Write Source, but it doesn't have that as an option for File Format. 

 

Any suggestions would be appreciated,

 

Brian

3 REPLIES 3
markcurry
12 - Quasar

Hi @brianvtran 

 

If Alteryx is creating the .bat file for you, you can run this from a command prompt which should hopefully show you what's the error you are getting.  Or you can add a 'pause' line at the end of the batch file, which will keep the command window open.

 

I don't think the batch file you have will work, you can't have a line "C:\Program Files\7-Zip" you, have to have this a two separate lines :

C:

cd\"Program Files\7-Zip"

 

Or you could just include the path to to the 7z.exe, like 

"C:\Program Files\7-Zip\7z" a -tzip "Folder to store zip file" "folder to retrieve file to zip" 

 

In the Run Command tool, if you set the Working Directory to the 7-Zip folder, (C:\Program Files\7-Zip), it will run the command from this folder, so you don't need to include the path.  So the following should work.

7z" a -tzip "Folder to store zip file" "folder to retrieve file to zip" 

 

I've attached a mock workflow, sorry I don't have 7zip installed to test it out, but hopefully this will point you in the right direction.  If not post the errors within the bat file you are getting.

 

 

 

 

 

I don't think t

 

 

brianvtran
7 - Meteor

Hey @markcurry

 

Using your advice about revising the bat file, I managed to run the workflow without erroring and I believe it successfully created the zip file. However, it took me a while to notice it worked because originally it kept creating a new "folder.zip" to place the zip file instead of directly putting the zip file into the initial output folder I intended. For example, I had the folder to store the zip file labeled "Output" but instead of placing the zip file into "Output" it would create a new folder called "Output.zip" to store the zip file. Is there a way to rework my bat file so that it directly places it into my intended "Output" folder? 

 

I also want it to output the zip file where it would be the "FileName.zip" rather than it be "Output.zip" in case I need to run the workflow to compress new files. I don't know what would happen since I don't have more files at the moment to test it on but I have a feeling it would just compress all the new data into the same "Output.zip" rather than creating individual zip folders for each new data file. Is there a way to account for such variability? 

 

Thanks,

 

Brian

brianvtran
7 - Meteor

@markcurry

 

Actually, I think I might have answered my own question. Up until to this point, I was just using Notepad to write my bat file but I took your advice and used Alteryx to write the batch file and it made it possible for me to dynamically change the filename of the zipped folder. My only problem is now is that when I open the zipped file, it includes the previous directory as well so instead of directly leading to the zipped file, it opens up the folder where I could find the csv file. Eg. Zipped Folder --> Output Folder --> csv file rather than Zipped Folder--> csv file. I know this is more of CMD question rather than an Alteryx one but if you have any suggestions for removing that extra folder from the zip, it would be much appreciated. Otherwise, thank you for helping me with my original problem. 

Labels