data-compression

Big file compression with python

你离开我真会死。 提交于 2019-11-30 00:37:57
I want to compress big text files with python (I am talking about >20Gb files). I am not any how an expert so I tried to gather the info I found and the following seems to work : import bz2 with open('bigInputfile.txt', 'rb') as input: with bz2.BZ2File('bigInputfile.txt.bz2', 'wb', compresslevel = 9) as output: while True: block = input.read(900000) if not block: break output.write(block) input.close() output.close() I am wondering if this syntax is correct and if there is a way to optimize it ? I have an impression that I am missing something here. Many thanks. Your script seems correct, but

Any theoretical limit to compression?

拈花ヽ惹草 提交于 2019-11-29 17:33:55
问题 Imagine that you had all the supercomputers in the world at your disposal for the next 10 years. Your task was to compress 10 full-length movies losslessly as much as possible. Another criteria was that a normal computer should be able to decompress it on the fly and should not need to spend much of his HD to install the decompressing software. My question is, how much more compression could you achieve than the best alternatives today? 1%, 5%, 50%? More specifically: is there a theoretical

Is there a practical way to compress NSData?

对着背影说爱祢 提交于 2019-11-28 20:47:31
I haven't seen any documentation on the topic, but that doesn't mean it doesn't exist. zaph Yes, compress the data with zlib. @Brad Larson posted on this: see here and added the code as well. There is a CocoaPod which uses Objective-Zip by flyingdolphinstudio. Following @Zaph & @Brad Larson's posts, below are the 2 methods gzipInflate and gzipDeflate that work just fine to compress/decompress NSData . (code reformatted from cocoadev.com/wiki/NSDataCategory #import "zlib.h" // don't forget to add libz.1.2.x.dylib into your project - (NSData *)gzipInflate:(NSData*)data { if ([data length] == 0)

How do I compute the approximate entropy of a bit string?

不问归期 提交于 2019-11-28 04:20:23
Is there a standard way to do this? Googling -- "approximate entropy" bits -- uncovers multiple academic papers but I'd like to just find a chunk of pseudocode defining the approximate entropy for a given bit string of arbitrary length. (In case this is easier said than done and it depends on the application, my application involves 16,320 bits of encrypted data (cyphertext). But encrypted as a puzzle and not meant to be impossible to crack. I thought I'd first check the entropy but couldn't easily find a good definition of such. So it seemed like a question that ought to be on StackOverflow!

Is there a practical way to compress NSData?

China☆狼群 提交于 2019-11-27 13:10:17
问题 I haven't seen any documentation on the topic, but that doesn't mean it doesn't exist. 回答1: Yes, compress the data with zlib. @Brad Larson posted on this: see here and added the code as well. There is a CocoaPod which uses Objective-Zip by flyingdolphinstudio. 回答2: Following @Zaph & @Brad Larson's posts, below are the 2 methods gzipInflate and gzipDeflate that work just fine to compress/decompress NSData . (code reformatted from cocoadev.com/wiki/NSDataCategory #import "zlib.h" // don't

How do I compute the approximate entropy of a bit string?

[亡魂溺海] 提交于 2019-11-27 00:20:48
问题 Is there a standard way to do this? Googling -- "approximate entropy" bits -- uncovers multiple academic papers but I'd like to just find a chunk of pseudocode defining the approximate entropy for a given bit string of arbitrary length. (In case this is easier said than done and it depends on the application, my application involves 16,320 bits of encrypted data (cyphertext). But encrypted as a puzzle and not meant to be impossible to crack. I thought I'd first check the entropy but couldn't

How to read data from a zip file without having to unzip the entire file

*爱你&永不变心* 提交于 2019-11-26 21:34:14
Is there anyway in .Net (C#) to extract data from a zip file without decompressing the complete file? Simply I possibly want to extract data (file) from the start of a zip file, obviously this depends if the compression algorithm compress the file in a deterministic order. DotNetZip is your friend here. As easy as: using (ZipFile zip = ZipFile.Read(ExistingZipFile)) { ZipEntry e = zip["MyReport.doc"]; e.Extract(OutputStream); } (you can also extract to a file or other destinations). Reading the zip file's table of contents is as easy as: using (ZipFile zip = ZipFile.Read(ExistingZipFile)) {