Hi,
I download the workflows using API, but they download in yxzp format and when I try to extract them to a folder, the error appears: 'Cannot open file as archive'. It wouldn't even open using Alteryx Designer, the error comes up saying the files are "not supported Package type". Does anyone have an idea how to solve this?
Solved! Go to Solution.
@akvilet
Redownload the .yxzp file via the API to ensure it isn’t corrupted during transfer. Double-check your API implementation to confirm no issues exist, such as incorrect endpoints or incomplete responses.
I don't get your exact error. when I download our workflows as YXZP using the API, sometimes a few of them corrupt. You can tell they are corrupt because they are 0 MB. Is that what is happening to you?
Regardless, I use a python tool to rename the YXZP files to ZIP files, then unzip them to a new folder.
# List all non-standard packages to be imported by your
# script here (only missing packages will be installed)
from ayx import Package
#Package.installPackages(['pandas','numpy'])
from ayx import Alteryx
import pathlib, zipfile
## Converts yxzp files to zip file in a given directory
## REPLACE ***** WITH YOUR OUTPUT FILE PATH FROM EARLIER
dir=pathlib.Path(r'\\pathname\pathname\') #example of how to define directory
for file in dir.glob("*.yxzp"):
print(pathlib.Path(file))
yxzp_file = pathlib.Path(file)
zip_file = yxzp_file.with_suffix('.zip')
yxzp_file.replace(zip_file)
# Unzips all .zip files into ./unzipped/'filename'
#unzip_dir = pathlib.Path.joinpath(dir, 'unzipped')
for file in dir.glob("*.zip"):
try:
file_path = pathlib.Path(file)
print(file_path)
zip_ref = zipfile.ZipFile(file_path)
#result_path = pathlib.Path.joinpath(unzip_dir, file)
zip_ref.extractall(pathlib.Path.joinpath(dir, 'unzipped', file.name))
zip_ref.close()
except:
continue
Obviously, put in your own pathname.