Blame view

volia/convert-old.py 756 Bytes
cd9123115   Mathias   Convert old ids w...
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
  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("
  ", "").split(" ")
              metas = splited[0].split(",")
              metas.pop(2)
              splited[0] = ",".join(metas)
              of.write(" ".join(splited) + "
  ")