I am new to Codea and I am having difficulty storing and recovering multiple data sets for future use. I need to be able to access a table for a particular data set based on a dropdon box selection. I am familiar with ‘saveLocaldata’ but this doesn’t look suitable for larges data sets. Any help, tips etc will be greatly appreciated.
you’ll need to flatten (“serialise”) your data into a delimited string, and then reverse the process when you need the data.
If your table has one dimension, you can convert to a string simply with str=string.concat(tablename)
There is no equivalent command to split a delimited string back into a table, but I have code for that if you need it.
If your table has more than one dimension, you will need to loop through the elements and attach them - not to a string, because that will be very slow - but to a one dimensional table. Only at the very end do you convert this to a delimited string with string.concat. This is pretty fast.
It you have multiple items and tables, you can store them separately using different tags.
If you provide more detail, we may be able to help further.
@dolbs - have a look at this tutorial on Saving and Loading Complicated Tables: http://codeatuts.blogspot.com.au/2012/09/tutorial-18-saving-and-loading.html
@Reefwing now don’t scare the poor lad! He’s only just arrived
@Ignatz - I think we posted simultaneously. Well if that is too scary check out my simple file manager example: http://codeatuts.blogspot.com.au/2012/09/tutorial-17-simple-file-manager-for.html
Hi@Dolbs. You can also try ‘lua serialize’ on google, you’ll get a bunch of ready to use serializers, just copy/paste the one that suits your needs.
Are you sure about string.concat()? I get a filed is nil error
Think it’s table.concat()
Tanks to all for the info and suggestions. I’ll work through the tutorials and see if I can find a suitable solution. All the suggestions will be of valuable help. Thanks again.
@dolbs - this tutorial may also be of use, it shows how to copy, store and recover 2D tables, ampong other things (scroll down the the heading “deep copying…”