unzipping one file from a zipped file which has many files.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
peddidsx
Premium Member
Premium Member
Posts: 55
Joined: Wed Dec 26, 2007 8:20 am

unzipping one file from a zipped file which has many files.

Post by peddidsx »

Hello Every One,

We developed lot of jobs which reads the mainframe files and loads them into staging area.

Usually we get zipped files which will contain 10 to 12 files in it, we unzip them and read them through CFF stage and load them into staging tables.

Now we are planning for production and we have lot number of files, its getting space problem while unzipping them.

So i would like to unzip a sing file from a zipped file which has many files and load them in to target.

I don't know how to unzip one file from a zipped file which has multiple files. I have gone through the posts and i got i need to use gunzip command but i need to extract only one file.

Thanks in advance
Rajesh Peddi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What was used to 'zip' them? Was it zip or gzip or something else? Regardless, they should all have help built in and usually you launch them with -h for help. For example:

Code: Select all

$ unzip -h
UnZip 5.52 of 28 February 2005, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment
  -x  exclude files that follow (in xlist)   -d  extract files into exdir

modifiers:                                   -q  quiet mode (-qq => quieter)
  -n  never overwrite existing files         -a  auto-convert any text files
  -o  overwrite files WITHOUT prompting      -aa treat ALL files as text
  -j  junk paths (do not make directories)   -v  be verbose/print version info
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
Examples (see unzip.txt for more info):
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
(edited to replace zip -h with unzip -h)
-craig

"You can never have too many knives" -- Logan Nine Fingers
peddidsx
Premium Member
Premium Member
Posts: 55
Joined: Wed Dec 26, 2007 8:20 am

Post by peddidsx »

Thanks Chulett,

Can you explain how the filter command in CFF stage would work.

Suppose if i have a zip file called A.ZIP and it contains abc, def and lmn files. IF i want to extract only abc file, is this should be my filter command.

Filter Command:
Unzip a.zip abc

I would like to know what should be given in FileName tab. I am little confused with how the filter command works.

Thanks
Rajesh Peddi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The Filter command is meant to be used to replace how the stage gets its input. Rather than reading a file directly, you supply a filter command that outputs something to 'standard out' and the stage will read that stream as input instead of opening a file. So while you would still put the file to work with in the Filename prompt, what you would need in the filter would be a command that manipulates the file in some way and outputs the results to standard out. The stage will put the two parts together, run the command and read the results.

If literally all you want to do is extract a single file from an archive, land and process it like normal, you'd need to do that 'before job' or as a separate step in a predecessor job.

To leverage the Filter, you'd need to find a way to get the file out of the archive and then get its contents cat'd to standard out. But that doesn't sound to me what you should be doing here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply