bollustrado
bollustrado
Reputation Top 5%
bollustrado exe
2 Snippets  (314th place)
Published
1 Channel
Created
1 Channel
Following
Jul 5, 2017
Last Visit
Oct 24, 2015
Registered
51 points  (480th place)
Reputation
Junior Code Generator
Junior Publisher
Junior Autobiographer
Senior Autobiographer
Junior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by bollustrado

public by bollustrado created Apr 17, 2016  5035  3  5  0

Unzipping file with progress bar

Unzipping file with progress bar
import gzip
from tqdm import tqdm


with gzip.open('file.log.gz', 'r') as f:
    for line in tqdm(f.readlines(), leave=True):
        print(str(line.strip(), encoding='utf-8'), file=open('temp.txt', 'a+'))
;

public by bollustrado created Apr 16, 2016  3584  0  4  0

size of gz

#size of decompressed .gz file (4 last bytes in integer)
import struct

with open('smarttube-2016-04-11.log.gz', 'rb') as f:
    f.seek(-4, 2)
    print(struct.unpack('I', f.read(4))[0])            
;