Category : gzip

I have a particular task at hand where I have two binary data buffers of exactly the same size (say a few megabytes) which I am compressing with Boost’s boost::iostreams::gzip_compressor. The buffers are different (but similar) in content and I want to estimate which of the two will compress better. Of course I can actually ..

Read more

We have zipped(deflated) content in the form of byte[] which was uploaded using Java language. Now we want to unzip it and then convert the byte[] to UTF_8 string in cpp. Sample working unzip code in Java that we want to replicate in cpp: public String unzipByteArray(byte[] file) { Inflater decompresser = new Inflater(); decompresser.setInput(file); ..

Read more

I need to replicate the output of the bash command cat <filename> | gzip | base64 using Python on Windows. So far I have attempted the following but without success. Can you please help? Bash $ cat primer.finder.variant.bed chr16 2358358 2358359 $ cat primer.finder.variant.bed | gzip | base64 H4sIAAAAAAAAA0vOKDI04zQyNrUAIihtyQUA8aLW7xYAAAA= Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, ..

Read more

I need to check using C++ if a file being opened is a gzip file or not. In Python I use the following code to identify if a file is gzipped: test_file = "junk.txt.gz" with open(test_file, "rb") as f: f_read_first_two_bytes = f.read(2) if f_read_first_two_bytes==b’x1fx8b’: print("The file is a gzipped file", end=’n’) What is the equivalent ..

Read more

I am writing into a compressed file using the gzip module of Python3.7 and then renaming that file. The expectation here is it should rename the actual name of the file as well but that’s not happening in Windows. (In Linux it’s working as expected.) Code: result_file = "C:Usersxyztest_data.csv.zip.filepart" with gzip.open(result_file, "wb") as f_res: f_res.write("some ..

Read more

I have multiple huge gzipped text files. I have to read the first and last n lines without loading the whole file into memory using head and tail like functions. For plain text files I use a tail like function similar to this answer. However I want to avoid unzipping the files first. I have ..

Read more