Commit cd9123115d5fc78a526ac68e1a9f8a26ebd23fc3

Authored by Mathias
1 parent 36b1fe28e1
Exists in master

Convert old ids with new one. In practice, it removes the third column of the id…

…s. (each column is separated by a comma)

Showing 1 changed file with 23 additions and 0 deletions Side-by-side Diff

scripts/data-management/convert-old.py
  1 +import argparse
  2 +from os.path import isfile
  3 +
  4 +
  5 +if __name__ == "__main__":
  6 +
  7 + parser = argparse.ArgumentParser(
  8 + description="Convert old files with wrong id to new one. Masseffect.")
  9 +
  10 + parser.add_argument("file", type=str, help="feature, x2x, or list file")
  11 + parser.add_argument("--outfile", type=str, default="out.txt", help="output file")
  12 +
  13 + args = parser.parse_args()
  14 +
  15 + assert isfile(args.file), "The given file does not exist."
  16 +
  17 + with open(args.file, "r") as f, open(args.outfile, "w") as of:
  18 + for line in f:
  19 + splited = line.replace("\n", "").split(" ")
  20 + metas = splited[0].split(",")
  21 + metas.pop(2)
  22 + splited[0] = ",".join(metas)
  23 + of.write(" ".join(splited) + "\n")