From one program I generate bunch of data and it is stored in a file. An example of the file's contents is
[[1, 2, 3], [4, 5, 6]]
As you can see, the data has the exact form of an array. Later in another program I want to read the data and use it. I am using
text_file = open('DataFile.txt')
lines = text_file.readlines() #We have only 1 line but this doesn't matter
The variable lines is an array of 1 element which is the string [[1, 2, 3], [4, 5, 6]]. I want this string to be again a numeric array. Just with the same delimiters etc. How can I do this?
import ast; ast.literal_eval(the_text)