Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

def path_to_file_list(path: str) -> List[str]:
"""Reads a file and returns a list of lines in the file"""
li = open(path, 'w')
with open(path, 'r', encoding='utf-8') as f:
lines = [line.rstrip('\n') for line in f]
return lines

def train_file_list_to_json(english_file_list: List[str], german_file_list: List[str]) -> List[str]:
Expand Down Expand Up @@ -33,9 +34,9 @@ def process_file(file):

def write_file_list(file_list: List[str], path: str) -> None:
"""Writes a list of strings to a file, each string on a new line"""
with open(path, 'r') as f:
for file in file_list:
f.write('\n')
with open(path, 'w', encoding='utf-8') as f:
for line in file_list:
f.write(line + '\n')

if __name__ == "__main__":
path = './'
Expand Down