Download ZIP file error zip.txt empty
- 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
Hello,
I am trying to download zip file and output them into a folder. I applied workflow called DownloadAndExtractZips(solution in one of other community post on how to download zip file) into my workflow but the process have an error. It seems like my zip.txt file (which includes all the name of the files inside the zip folder) is empty. The workflow is not fetching the names properly. The zip file is password protected so I believe this may have caused the issue. What are the commands I need to add to be able to get the file names?
Thank you.
Solved! Go to Solution.
- Labels:
- Developer Tools
- Download
- Macros
- Output
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @MinhTa - Can you confirm which of the files is password protected?
- base64
- zip file
- files in the zip file
The error you provided appears that the CSV file inside the zip file requires a password, but want to confirm before we think about next steps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Maskell_Rascal I just confirmed this with higher up and only the zip is password protected. Files inside the zip are not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @MinhTa
Lets try this again! 😀
I added a text input that is reading into Python with a password. This password is then fed into the zip file when opening/extracting. You will need to update the text input file with your password to make this work. You could also feed in a file stored locally on your computer, so the password isn't saved in the actual workflow. Just make sure that the file has a column labeled "Password".
from ayx import Alteryx
import pandas as pd
import zipfile
import glob
import base64
filepath = Alteryx.read("#1")
file = filepath['File'].iloc[0]
file2 = filepath['FileDecoded'].iloc[0]
pswd = bytes(Alteryx.read("#2")['Password'].iloc[0],'utf-8')
with open(file, 'rb') as file_input, open(file2, 'wb') as file_output:
base64.decode(file_input, file_output)
for zip_file in glob.glob(file2):
zf = zipfile.ZipFile(zip_file)
dfs = [pd.read_csv(zf.open(f, mode='r', pwd=pswd), header=None, sep=",") for f in zf.namelist()]
df = pd.concat(dfs,ignore_index=True)
print(df)
Alteryx.write(df,1)
Let me know if this one works for you.
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @Maskell_Rascal,
Thank you very much, I was able to extract the file successfully (saw the data appear in the output section). There is 1 question I have left is how can I distinguish where the data came from (from which file)? I want to output them into excel or csv file so I need to way to distinguish them when output. The zip file I have only 1 file inside but lets say I have more than 1 then how can I solve this.
Thank you, very grateful for your help.

- « Previous
- Next »