In 2.1, I saved a table as a text file with the new feature of “new text file” ,the text file name is myTable, see below:
Then I use code:
t1 = readText(“Documents:myTable”)
Now t1 is a long string, but I wish t1 to be a table. Which function or parameter can do it? or I have to write a function to convert a struct string to a table myself?
You have to create you’re own function to create a table. Or do a forum search because there have been many examples of creating a table from a string.
The easiest way I would guess would be to use a JSON library to convert your tables to and from a JSON string.
There are a couple of good JSON libraries on the forum and as JSON is a recognised format you’ll find a lot of third party utilities support exporting their data in JSON format.
Got it, thank you! @dave1707
@TechDojo, thank you! I will learn JSON soon.
@binaryblues, if you have a table in a string,
loadstring() will read it for you, saving a table into a string is a bit more complicated, I’ll dig out the code i’ve been using and share it here later if you need it
@JakAttak, thanks a lot! I think I have understood your meaning. And success!
This is my code:
fileTableString = readText(“Documents:myTable”)
fileTableString = loadstring("return "..fileTableString)
fileTable = fileTableString()