Problem is caused by the \n
(newline) characters. The Table
format for Import
uses \n
to delimit rows. Can you modify the Python code to not insert a newline between [ ]
? If not, probably best to use sed
or awk
to remove those newlines. You could also import as a string and munge it using WL. e.g.
import = Import["nodes.txt", "Text"];
string = import // StringReplace[{"\n" -> " ", "[" -> "{", "]" -> "}"}] // StringReplace[" " -> ","];
list = "{" <> string <> "}" // ToExpression