There is a difference between compression of files and archiving of files.
Compression is the reduction of volume of a file.
Archiving is storing of one of multiple files in an archive file with or without compression.
A file with extention '.gz' is a compressed file. So your task sounds incorrect.
But in *nix environments we often use compression of a tar archive, usually such a file has '.tar.gz' or '.tgz' extention. Also there can be a different type of archive compressed (or different extention used).
So I guess you ask how to extract a file from a compressed archive. But to answer your question, some more details about a type of your archive required.