Import CSV Directly from Password Protected Zip FIle

Reply
New Contributor
Posts: 3

Import CSV Directly from Password Protected Zip FIle

[ Edited ]

Hi, 

  I am using code mentioned below to importing a csv file directly from a zip file and the code is working fine, but when i apply the same code on password protected zip file it doesnt work. Is there anyway i can get this to work by mentioning password some where in the code. Any other method would also be appreciated 

 


FILENAME ZIPFILE zip 'K:\check1.zip' ;
DATA newdata ;
INFILE ZIPFILE(new.csv)
DLM = ','
MISSOVER
DSD
LRECL = 32767
FIRSTOBS = 1;

informat var1 $ 30. ;

informat var2 $ 30. ;



input var1 $
var2 $
;
RUN;

 

 

Thanks for your help Smiley Happy

Super User
Posts: 1,107

Re: Import CSV Directly from Password Protected Zip FIle

There is similar discussion happend on this topic, here is a thread of the same. Hope it helps.

 

https://communities.sas.com/t5/SAS-Procedures/Import-Password-Protected-Text-Files/td-p/101692

 

Thanks,
Jag
New Contributor
Posts: 3

Re: Import CSV Directly from Password Protected Zip FIle

Hi Jagdishkatam,

 

Thanks for your quick response. Actually i have seen the discussion you posted before posting my question but couldn't get a working solution. There was one solution provided for password protected file but that was for UNIX and i am working on windows OS. Other methods which were mentioned requires additional software installation which i am not allowed to do. Hope this clarifies my query.

 

Thanks

Esteemed Advisor
Posts: 6,646

Re: Import CSV Directly from Password Protected Zip FIle

The SAS Filename for ZIP does not provide the option to enter a password, so you must use an external means to unzip the archive.

Since there are perfectly working free (as in beer and speech) and currently maintained (de)compression tools available (eg 7-zip), not having them installed is (IMHO) just foolish.

In our organization (large international insurance), 7-zip is installed per default as a standard tool on all desktops (the SAS Server runs on AIX and therefore has compression tools available out of the box). So have your admin install it (or an alternative) on your SAS host (server or desktop).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: Import CSV Directly from Password Protected Zip FIle

Hi Kurt,

 

Currently i am doing what you have suggested but its's  a lot of manual work as i keep getting these files on regular basis. As you said that FILENAME for ZIP does not accept passwords, is there any other command which does and thus can save me lot of time ?

 

Thanks

Esteemed Advisor
Posts: 6,646

Re: Import CSV Directly from Password Protected Zip FIle


saslearner3 wrote:

Hi Kurt,

 

Currently i am doing what you have suggested but its's  a lot of manual work as i keep getting these files on regular basis. As you said that FILENAME for ZIP does not accept passwords, is there any other command which does and thus can save me lot of time ?

 

Thanks


Not within SAS. And if you get such files on a regular basis, you have to set up a process that gets you the necessary passwords so you can do the extract automatically.

Also, if you get such files regularly, your IT people MUST give you the tools needed for your work.

How do you obtain the necessary passwords, anyway?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Import CSV Directly from Password Protected Zip FIle

Sorry, just wanted to add here, as seen the "getting these files on regular basis".  Why are the files password protected then?  It sounds to me like your using perhaps email or something to send zipped files and then sending password separately - have seen this done a fair bit and its really not secure at all.  ZIP is not a great protection method anyways.  If your doing regular transfers of data then you will be wanting to to use some sort of secure file portal (most companies have these) or SFTP.  Emailing data around is one great way to lose it or worse.

 

Speak to your IT group, they will have something in place.  Forget the whole password protected zips.

Esteemed Advisor
Esteemed Advisor
Posts: 7,203

Re: Import CSV Directly from Password Protected Zip FIle

This isn't really a SAS related question.  You recieve a third party file, and then you should follow the process set out in your import process document, aligning with the data transfer document you will have created.  Thus as part of that process, you will store the file somewhere (pull from somewhere, have them post etc. then save to a know location).  Then you would unpack the file, perform routine checks on it, then validate it against your data import agreement.  Then finally move it to production for further processing - hence the further processing shouldn't care about ZIP files or anything like that.  

Ask a Question
Discussion stats
  • 7 replies
  • 142 views
  • 4 likes
  • 4 in conversation