forked from proydakov/supercell-resource-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder_csv.py
More file actions
executable file
·38 lines (27 loc) · 819 Bytes
/
decoder_csv.py
File metadata and controls
executable file
·38 lines (27 loc) · 819 Bytes
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
#!/usr/bin/env python3
import os
import sys
import lzma
import glob
def process_file(path):
basename = os.path.splitext(path)[0]
decodedname = basename + ".decoded.csv"
print("process:", path, "->", decodedname)
with open(path, 'rb') as f:
data = f.read()
tempdata = bytearray()
for i in range(0, 8):
tempdata.append(data[i])
for i in range(0, 4):
tempdata.append(0)
for i in range(8, len(data)):
tempdata.append(data[i])
with open(decodedname, 'wb') as f:
unpack_data = lzma.decompress(tempdata)
f.write(unpack_data)
def process_dir(path):
for filename in glob.iglob(path + '/**/*.csv', recursive=True):
if "decoded.csv" in filename:
continue
process_file(filename)
process_dir(sys.argv[1])