I am currently working with a file with more than 2 million lines. I've separated the lines into lists of elements (ex: [a,b,c,d]
= 1 line, words separated).
I'm trying to use the following code to go through all the lines:
for a in aud:
for esps in final:
if a[0] in final[esps]:
a[0] = esps
In the first for loop I'm referring to the 2 million+ lines. In the second for loop it goes through a dictionary with 2010 keys, each key with probably at least 50 corresponding values. I want to find the a[0]
element in the lines that are equal to the values in the dictionary. If they match, I change the a[0]
element in the selected line to the value of the key of the dictionary.
The problem is that this code takes ages to run and I don't understand much (nothing) about optimization and how to run this much faster. I would thank a lot if anyone could tell me how to do something like this faster.