Page 1 of 1

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

Posted: Wed Sep 10, 2008 1:45 pm
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

Posted: Wed Sep 10, 2008 2:14 pm
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)

Posted: Wed Sep 10, 2008 2:50 pm
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

Posted: Wed Sep 10, 2008 3:10 pm
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.