bollustrado
bollustrado
Reputation Top 5%
bollustrado exe
2 Snippets  (225th place)
Published
1 Channel
Created
1 Channel
Following
Jan 4, 2017
Last Visit
Oct 24, 2015
Registered
51 points  (394th place)
Reputation
Junior Code Generator
Junior Publisher
Junior Autobiographer
Senior Autobiographer

Recent Snippets See all snippets by bollustrado

public by bollustrado created Apr 17, 2016  325  2  3  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  229  0  3  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])            
;