I have a large text file that includes so many lists. Each list includes random numbers as follows. Test file:
[-1460,-1460,-1460,-1460,-1460,0,-1460,0,-1460,-1460,-1460,45,-1460,-1460,-1460,-1460,-1460,-1460]
[250,-1250,36,-1250,-1250,33,-1250,-1250,-1250,-1250,-1250,-1250,-1250,-490,-1243,-1250,-1250,-1250,-1250,-1250,33,-1250,33,-1250,-1250,-1250,-1250,-1250,-1250,33,-496,-1243,-1250,33,-1250,-1246,-1250,-1250,-1250,-1250,35,-1250,-1250,33,-1250,-1250,-1250,-1250,-1250,-1250,-1250,-1250,33,-1250,-1250,-1250,-1250,-525,-1250,33,-259,-1250]
[2,-1232,34,34,34,0,0,-1232,-1232,-1232,-1232,34,34,-1232,-1232,-1232,-1232,-1232,-1232,-1232,-1232,34,34,-1232,34,-1232,34,34,-1232,-1232,-1232,39,-1232,34,-1232,-1232,-1232,34,-1232,0,0,34,-1232,-1232,-1232,-1232,-1232,517,0,34,34,34,-1232,-1232,-1232,-1232,-1232,-1232,34,-1232,-1232,-1232,34,-1232,34,-1232,34,-1232,34]
......
First, I want to count how many lists are there in the text file. Then, I want to extract every list separately for further processing.
I created a code to read the text file, but it read the whole file contents as a one-string variable, as follows:
# opening the file in read mode
my_file = open("R1E1.txt", "r")
# reading the file
data = my_file.read()