Hello
I use python itertools.permutations to generate a permutations of a certain list of content. When I try to store it in a list, I run out of memory because of the large number of possibilities. I tried to store it in a text file, but I need to recall these permutations at my code later to choose one of the possibilities which should be in a data type of a list. Can you please help me find a way to recall the saved list so I can access the saved permutations as a list not as a string. Thank you
For example
from itertools import permutations
text_file = open(“comb3.txt”, “w”)
action_list =
UEs = [[4,5,6],[1,2,3]]
List_UE = [list(p) for p in product(*UEs)]
comb = permutations(List_UE, int(3))
for i in comb:
unique_elements, counts= np.unique(list(i), return_counts=True)
if all(counts == 1):
text_file.write(“{},”.format(list(i)))
action_list.append(list(i))
with open(“comb3.txt”) as file:
content = file.readlines()
print([content])
Here I access the content as a string; I want it as a list