convert-old.py
756 Bytes
import argparse
from os.path import isfile
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Convert old files with wrong id to new one. Masseffect.")
parser.add_argument("file", type=str, help="feature, x2x, or list file")
parser.add_argument("--outfile", type=str, default="out.txt", help="output file")
args = parser.parse_args()
assert isfile(args.file), "The given file does not exist."
with open(args.file, "r") as f, open(args.outfile, "w") as of:
for line in f:
splited = line.replace("\n", "").split(" ")
metas = splited[0].split(",")
metas.pop(2)
splited[0] = ",".join(metas)
of.write(" ".join(splited) + "\n")