Category : gzip

I’m trying to compress a text file into a gzip (.gz) file, in Python, using the following code: import shutil, gzip text_file = ‘C:Userslenovo-miguelDownloadspythontext_file.txt’ gz_file = text_file + ‘.GZ’ with open(text_file, ‘rb’) as f_in: with gzip.open(gz_file, ‘wb’) as f_out: shutil.copyfileobj(f_in, f_out) .GZ file image The code works, the .gz file is created with the correct ..

Read more

This might be a simple question but I can’t seem to find the answer to this or why it is not working on this specific case. I want to read large files, they can be compressed or not. I used contextlib to write a contextmanager function to handle this. Then using the with statement I ..

Read more

I’m using django-bakery trying to gzip a large file which is about 1MB in size. However, it’s failing with the error: [2021-11-08 09:59:37] myapp.views DEBUG Target path: /project/build/index.html [2021-11-08 09:59:37] bakery.views.base DEBUG Gzipping to osfs:////project/build/index.html Traceback (most recent call last): File "/project/.env/lib/python3.7/site-packages/fs/osfs.py", line 646, in open **options OSError: [Errno 28] No space left on device: ..

Read more

I read a json file from S3 like this: json_file = s3_resource.Object(bucket_name=’test’, key=’new.json’ json_content = json.loads(file_content) …. gzipped_content = gzip.compress(json_content) after reading the json_content, I want to gzip it. But I am not sure what to put inside the gzip.compress() function as a parameter. Currently, I get an error that: { "errorMessage": "memoryview: a bytes-like ..

Read more