Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.
SOLVED

Get File creation date from files within a zip file

Highlighted
6 - Meteoroid

I have a use case where I can't download the zip files. We are reading directly (using Alteryx Designer) from the zip file which has multiple files with same schema (but different data sets). I need to know how we can get the file creation dates of the files that are in the zip file.

If the zip file has 4 'csv' files, how would I get the file creation date and time so that I can figure out which is the oldest file and which is the newest. The Directory tool doesn't work as it will provide me date/time for only the zip file. I actually need the date/time for the files within the zip files.

Appreciate any ideas.

Highlighted
Alteryx Certified Partner

@pankajk - based on my experience the Input tool can only read one csv file at a time from any given zip file (which contains multiple csv files).

 

In terms of a solution, one approach I can think of is to run a batch command (via Run Command tool) and unzip the zip file into its individual csv components (reference link). Then use the Directory tool to identify the file that suits your criteria and read it. Let us know if this wont work in your case.

Highlighted
17 - Castor
17 - Castor

Hi @pankajk 

 

If you're familiar with Python, the zipfile library has a ZipInfo object that returns the name, last modified date/time, etc for the files within a zip file

 

Dan

 

Highlighted
Alteryx Certified Partner

Thanks @danilang! I wish I had thought of that solution:)

Highlighted
6 - Meteoroid

Thanks @danilang - never used Python before..... do you think you can share a small workflow on how this would work? But seems like a good solution as I am reading the link you provided.

14 - Magnetar

If you take @danilang's awesome suggestion, type zip python in the community search bar at the top, it brings you this this awesome post!

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Reading-Multiple-Files-Of-Your-Choice-...

 

This is a super idea and a great excuse to start playing with the Python tool!

Labels