Advertisement
craigoej

Untitled

Oct 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import sys
  3.  
  4. lines = []
  5. with open(sys.argv[1], "rt") as input:
  6. with open(sys.argv[2], "r") as template:
  7. for line in input:
  8. lineArray = line.split('\t')
  9. lines.append(lineArray);
  10. templateText = template.read()
  11. for index, line in enumerate(lines):
  12. id = ""
  13. if index == 0:
  14. continue
  15. out = templateText
  16. for line_index, val in enumerate(line):
  17. if lines[0][line_index] == "ID":
  18. id = val
  19. temp = templateText
  20. key = "<<" + lines[0][line_index].strip() + ">>"
  21. out = out.replace(key, val)
  22. with open(f"{id}.txt", "w") as output:
  23. output.write(out)
  24. print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement