Compression of a file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Compression of a file

I am so curious to know how a large file is compressed and extracted after some time

3rd Nov 2019, 11:28 AM
Sanka Deva Dutt
Sanka Deva Dutt - avatar
7 Answers
+ 1
I've had problems extracting from RAR files with some sort of corruption and end up with an error and usually some hex and lots of zeros
3rd Nov 2019, 12:59 PM
Michael Smyth
0
Take this sequence of numbers. 0000444446655553677 That is 20 numbers long But you could also write it as 4*0,4*5,2*6,5*5,36,2*7 So by saying there are 4 zeros, followed by 5 fours then 2 sixes etc.... You go from 20 numbers long to 12 numbers. That's a very basic way of compressing a file.
3rd Nov 2019, 11:55 AM
Michael Smyth
0
What about texts where the letters are not in a sequence and moreover it can even contain numbers.How to extract that?
3rd Nov 2019, 11:57 AM
Sanka Deva Dutt
Sanka Deva Dutt - avatar
0
It's a similar method, a good compression algorithm would count how many A,B,C etc & 1,2,3 etc...so it would be this file has 36 A character in it 45 zeros etc... then entered into an array to keep track of the line that character/number is on. I'm just not sure exactly how to go from that to extracting it into its original form. Perhaps try and find currently written compression algorithms and learn from that.
3rd Nov 2019, 12:02 PM
Michael Smyth
0
Thank you 😊
3rd Nov 2019, 12:11 PM
Sanka Deva Dutt
Sanka Deva Dutt - avatar
0
Thanks for the post on the topic Kit Delano Cat, I'll certainly check it out.
3rd Nov 2019, 12:53 PM
Michael Smyth
0
Use python zip module
4th Nov 2019, 10:09 AM
RiseUp4Rojawa