Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I downloaded tags from booru and then also ran them through the WD tagger. Not copy, not prepend, not append — I want to MERGE. Without duplicate tags.
- # i love github copilot
- import sys
- import re
- if len(sys.argv) < 3:
- print("Usage: python3 merge.py [file1] [file2]")
- exit()
- file1 = sys.argv[1]
- file2 = sys.argv[2]
- with open(file1, "r") as f:
- tags1 = f.readlines()
- with open(file2, "r") as f:
- tags2 = f.readlines()
- # tags are split by comma
- tags1 = re.split(", ", tags1[0])
- tags2 = re.split(", ", tags2[0])
- tags1 = set(tags1)
- tags2 = set(tags2)
- tags = tags1.union(tags2)
- print(tags)
- # print to new file
- with open("merged.txt", "w") as f:
- f.write(", ".join(tags))
Advertisement
Add Comment
Please, Sign In to add comment