0

I have two nested lists one with around 10K x 6 elements.Other nested list has 28K * 15 elements.

This is the pseudo logic I'm implementing using nested loops for doing approximate comparison

if nested_list_1[iter_1][0] and nested_list_1[iter_2][3] appoximate_ratio > 85:
    if nested_list_1[iter_1][2] and nested_list_1[iter_2][4] appoximate_ratio > 85:
        save_to_another_list

I can use nested loops to iterate over each element and do the approximate comparison. But it is taking a lot of time. Is there a way to minimize the consumption time?

for i in range(len(nested_list_1)): #length 10000
    data_1_part_1 = nested_list_1[i][0] 
    data_1_part_2 = nested_list_1[i][1] 

    for j in range(len(nested_list_2)): #length 28000
        data_2_part_1 = nested_list_2[j][9] 
        data_2_part_2 = nested_list_2[j][15]

        if fuzzy_ratio(data_2_part_1,data_1_part_1) > 85:

            if fuzzy_ratio(data_2_part_2,data_1_part_2) > 85:

                writing_csv_file(nested_list_1[i])
Saad Saadi
  • 1,031
  • 10
  • 26
  • Hi Saad Saadi, to better understand your problem could you give a workable example of your code instead of pseudo logic because it's difficult to help. A [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) would be ideal. – EvensF Mar 24 '20 at 23:00
  • I added the code part. I'm using `fuzzy-wuzzy` in python – Saad Saadi Mar 25 '20 at 09:13
  • If I take your code and try to run it, it won't work. For example, where are `nested_list_1` and `nested_list_2` is defined? – EvensF Mar 29 '20 at 14:06

0 Answers0