List the contents of many zip files

Quick question that I’m hoping has a simple solution. I have a folder full of zip files (one per month for quite a long period) then each file contains a large amount of files.

What I need is basically a list of all the files in all the zips, ideally without having to unzip them all. At the moment I don’t need any information from within the files, I just need a list of all the filenames I can cross reference against something else.

Can a list files node read inside a zip, or is there something similar?

Possible with a script node and then sth like this

from zipfile import ZipFile

with ZipFile(‘file.zip’, ‘r’) as zip:
for info in zip.infolist():
print(info.filename)

br

2 Likes

@phick indeed one idea could be to employ the KNIME Python integration to get such a list:

2 Likes

That looks promising, I’ll investigate the python nodes. I was thinking python would be a way of doing it, but had knime plans for the resulting list of files once i have it.

1 Like

The component mlauber posted worked perfectly! I slightly amended it to allow the directory to be manually configured, but it produces the exact list I wanted.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.