def parse_txt_files(): """ This is a hacking way of parsing txt files You might find it useful sometimes. :) """ parser = XMLStreamParser("", "crf_files/final_model", "") note_dir = "test/data/note_texts" parsed_note_dir = "test/data/note_texts_parsed" if not os.path.exists(parsed_note_dir): os.mkdir(parsed_note_dir) for file in os.listdir(note_dir): new_string = None with open(note_dir + "/" + file) as f: if file.endswith(".txt"): string = f.read() new_string = parser.add_line_break(string) with open(parsed_note_dir + "/" + file, "w+") as wf: wf.write(new_string)