I am trying to read a text file and I want to convert the below string to a 2d array.
File Data:
[[],['java','j2ee','spring'],['.net','c#','mysql'],['php','mysql']]
My Code:
with open("test.txt") as myfile:
sentences = np.array(myfile.readline(),dtype=object)
print(sentences)
It returns the below array
array("[[],['java','j2ee','spring'],['.net','c#','mysql'],['php','mysql']]", dtype=object)
I want following output
array([[],['java','j2ee','spring'],['.net','c#','mysql'],['php','mysql']],dtype=object)