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

Get File creation date from files within a zip file

pankajk
10 - Fireball

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.

5 REPLIES 5
AbhilashR
15 - Aurora
15 - Aurora

@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.

danilang
19 - Altair
19 - Altair

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

 

AbhilashR
15 - Aurora
15 - Aurora

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

pankajk
10 - Fireball

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.

DavidP
17 - Castor
17 - Castor

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