If a .zip file contains all of the information of the original, just in less space, why does it have to be unzipped to access any of it?

802 views

If a .zip file contains all of the information of the original, just in less space, why does it have to be unzipped to access any of it?

In: 1276

43 Answers

Anonymous 0 Comments

Reading/writing compressed data is more complicated. Good compression algorithms remove all the duplicate data, but if you want to read it back again it takes a lot more work to reconstitute the original data. Updating anything requires essentially rewriting the entire file. Less-effective compression mechanisms limit the effort but trade off compression efficiency.

An application would prefer to just seek to byte 1000 and read the next 5 bytes, then update it in place to a different value. Not read entire file, update in place, rewrite entire file.

Anonymous 0 Comments

Imagine you have a book. Now, instead of being in plain English, it is written in shorthand to save on paper. To read the book you would need to read a sentence and then use a dictionary to translate it to plain English. As you can imagine, this would take a heck of a lot longer than just reading a book that is written in English. Now imagine your friend Bob who doesn’t know how to use a dictionary, how is he going to read the book? He could get you to translate it for him as he reads it but that would take even longer. What if the book was a cook book? Would you be able to translate the book quickly enough for Bob to be able to make a recipe from it? Or would the extra time mean that the dish Bob was cooking gets ruined through over cooking?

Now, a .zip file is like a book that has been translated into shorthand to save space but instead of a book it is data and instead of shorthand it is a dictionary that has been made up at the time of zipping the file based on what is in the data (e.g. there is no need for a shorthand version of “a triumphant roar was heard” if it doesn’t appear in the data). A program (e.g. Notepad) is like Bob who doesn’t know how to use the dictionary so it needs someone else to translate the zipped file for it.

There are transparent compression methods used fairly often in computers though. For example, Windows has the ability to compress data in memory so that you can store more data in it and it does this without the knowledge of whatever owns the data – the downside is that the data needs to be decompressed for the program to use it which slows down how quickly the data can be accessed. Windows can also do this for data held in storage (like on SSDs and HDDs) but, again, this slows down how quickly the data can be accessed so it isn’t used by default.

Anonymous 0 Comments

You know these vacuum bags in which you store your winter coats during the summer? You put in the coats, seal the bag and suck out all the air with a vacuum. You cannot use the coat in this state, as you traded volume for usablity. Outside the bag, the air serves a purpose. It keeps you warm and makes the coat soft.

A zip file does the same thing as a vacuum bag. It takes out zeroes on a row, ones on a row, abbreviates patterns and so on. By doing so, it makes the file smaller but unreadable for the computer. Therefore the process has to be reversed to make it readable again. This takes time and energy hence why not all files are zipped by default. Kinda similar to how you don’t put your coat in the vacuum bag after every use.

Anonymous 0 Comments

I vacuum sealed all your shirts and put them in a suitcase so you can get them all onto the plane. I “compressed” them to get all the air out so I could pack all of them in. You won’t be able to wear them until you unpack at your destination.

Your clothes are the files, compressing the air out and vacuum sealing is the “zipping”, the fact they’re still your shirts just squished is the “all the information of the original”, and unpacking so you can wear your shirt is the “unzipping before access”.

That should about explain it.

Anonymous 0 Comments

Consider it like Lego.

If you have built a spaceship, it takes up a certain size of box.

Take all the pieces apart and reorganize them into tight rectangular stacks, and you can fit them all in a smaller box. You can even fold the instructions into the box.

All of the information is still there to reform the spaceship, but you can’t use it like a spaceship directly.

Anonymous 0 Comments

OK, so imagine a file is basically a string of 20 zeroes.

that can be shortened from 00000000000000000000 to 20 x 0 when zipped.

some programs are built to understand that, and the file doesn’t need to be unzipped.

But most will not understand this new format

Anonymous 0 Comments

Speed of access is really the whole of it. Zipping files just trades off the time it takes to compress or decompress them for the space they take in storage, and you can’t access any particular part of the data without decompressing the entire file.

Anonymous 0 Comments

While others gave great ELI5 explanations, I‘ll try to give you an example of data compression.

For simplification I‘ll use text. Normally text is saved in 8bits per letter/sign. Computers always need the 8bits(8 times 0 or 1) to work with it or show it on your program. If we take the word Oklahoma it would be 01001111(O)01101011(k)01101100(l)01100001(a)01101000(h)01101111(o)01101101(m)01100001(a)

To zip it we try to find a way to shorten it, cause we’re not using the whole alphabet. For example
a=00,O=01,k=100,l=101,h=110,m=1110,o=1111

So Oklahoma would be: 01100101001101111111000

If we compare it to the original: 010011110110101101101100011000010110100001101111011011010110000100100000

Wow nice we have the same information but way less storage was used. Unluckily our computer still wants an 8bit long data format to work with it so we need to unzip it again. The benefit is though you can share the compressed data to your friend using less data. Or you can store more files on your disk.

Anonymous 0 Comments

Because when you pack up your kitchen, living room and bedrooms in a Uhaul and then move to a new house you can’t just dump it all out and expect your kitchen and living room and bedrooms to be setup. You packed everything into the Uhaul and you know where it all goes.

Anonymous 0 Comments

It doesn’t have to be unzipped to access any of it. You can read the footer where the index and metadata are stored, and use it to start reading any of the entries out very easily. Entries can be compressed or uncompressed, or a mix of both within the same archive. It’s not hard to write a program that can read out of a zip file without extracting all of it!