Readlines and Open

Hey guys! I have read the file anglizismen.txt with the python function open.How can I insert the anglicisms into an empty frequency table? Next step I should open another file : europarl.de-en with the python function open. But it didn’t work out ... this file I Must iterate line by line with python function readlines over the file. In the end I must check for each word of each line whether it is listed in the anglicisms frequency table . If it is so I must increase the number of occurrences of this anglicisms by one to collected for each anglicism the frequency of occurrence in the corpus . I don’t have any idea how I should start https://code.sololearn.com/c5z4cxpm8QR8/?ref=app

12/4/2019 9:36:14 PM


3 Answers

New Answer


I think you should read on file handling again... Everything you did from the first line is wrong. btw this is a pseudocode of what you should do in copying the file to another file with open("Europarl.de-en.txt", "w") as f: for content in previous_file: f.write(content)


Not sure what you mean by "frequency table", I can only assume you mean a list...so.. how about something like this to start:- f = open("test.txt", "r") mylist = f.read().split() print(mylist) Why are you doing it line by line, is there a reason you have to it that way?


Here's a start...three more line of code and.... it's done...(If I understand what your trying to do). frequency = [] anglizismen = open("anglizismen.txt", "r").read().split() europarl_de_en = open("europarl.de-en.txt", "r").read()