-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathother.py
More file actions
46 lines (39 loc) · 1.42 KB
/
other.py
File metadata and controls
46 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import rarfile
import gzip
import numpy as np
import lzma
import gzip
import shutil
import glob
def compress_to_xz(input_path,output_path):
with open(input_path,'rb') as input:
with lzma.open(output_path,'wb') as output:
shutil.copyfileobj(input,output)
def compress_folder_to_xz(input_dir,output_dir):
file_list = glob.glob(input_dir+'/*')
num_total = len(file_list)
iter=0
for input_path in file_list:
print(iter,'/',num_total)
compress_to_xz(input_path,output_dir + input_path.replace(input_dir,'')+'.xz')
iter +=1
def compress_to_gz(input_path,output_path):
with open(input_path,'rb') as input:
with gzip.open(output_path,'wb') as output:
shutil.copyfileobj(input,output)
def compress_folder_to_gz(input_dir,output_dir):
file_list = glob.glob(input_dir+'/*')
num_total = len(file_list)
iter=0
for input_path in file_list:
print(iter,'/',num_total)
compress_to_xz(input_path,output_dir + input_path.replace(input_dir,'')+'.gz')
iter +=1
if __name__=='__main__':
#compress_folder_to_xz('/data/zdxy/DataSets/MLC_16c/multi_channle_data_16','/data/zdxy/DataSets/MLC_16c/multi_channle_data_16_xz')
compress_folder_to_gz('/data/zdxy/DataSets/MLC_16c/multi_channle_data_16','/data/zdxy/DataSets/MLC_16c/multi_channle_data_16_gzip')
'''
npy_data = f.read()
arr=np.frombuffer(npy_data)
print(arr)
'''