Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import re
- def extract(source_file, destination_file, encoding="utf-8"):
- source = open(source_file, mode='r', encoding=encoding)
- with open(destination_file, mode='w') as destination:
- while True:
- line = source.readline()
- if line == "":
- break
- if str.startswith(line, "Dialogue: "):
- destination.write(re.sub("{.*}", "", line.split(",")[9]))
- def main():
- if(str.endswith(sys.argv[0], "extractor.py")):
- sys.argv.remove(sys.argv[0])
- arglen = len(sys.argv)
- if arglen == 2:
- extract(sys.argv[0], sys.argv[1])
- elif arglen == 3:
- extract(sys.argv[0], sys.argv[1], sys.argv[2])
- elif arglen == 1 and (sys.argv[0] == "-h" or sys.argv[0] == "--help"):
- print("Usage: extractor <source file> <output file> [encoding]")
- else:
- print("Malformed input. Type 'extractor -h' for the expected form of input.")
- main()
Add Comment
Please, Sign In to add comment