forked from reusu/FFXIVChnTextPatch
-
Notifications
You must be signed in to change notification settings - Fork 87
7. Scripts
GpointChen edited this page Jan 11, 2023
·
1 revision
A simple python script is used to remove all non-string content and unused files.
import os
import csv
def str_only(path, save_path):
os.makedirs(os.path.dirname(save_path), exist_ok=True)
with open(path, 'r', encoding='UTF-8', newline='') as f:
spamreader = csv.reader(f, delimiter=',')
target = [0]
try:
for i, line in enumerate(f):
if i == 3:
a = line.replace('\r\n', '').split(",")
for j in range(len(a)):
if a[j] == 'str':
target.append(j)
break
if len(target) > 1:
with open(save_path, 'w', encoding='UTF-8', newline='') as f2:
spamwriter = csv.writer(f2, delimiter=',')
f.seek(0)
for i, row in enumerate(spamreader):
spamwriter.writerow(
[row[x].replace('\r\n', '\n') for x in target])
except Exception as e:
print(e)
print(path)
print(i, row)
if __name__ == '__main__':
root = 'D:\\FFXIV\\FFXIVChnTextPatchGP\\FFXIVChnTextPatch\\resource\\rawexd-full\\'
for path, subdirs, files in os.walk(root):
for name in files:
str_only(os.path.join(path, name), 'rawexd-cut\\%s' %
os.path.join(path, name).replace(root, ''))