[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Saving a table in file
- From: Petite Abeille <petite.abeille@...>
- Date: Sun, 7 Mar 2010 21:54:57 +0100
On Mar 7, 2010, at 7:09 PM, Luciano de Souza wrote:
> But, how to save it in a file?
As mentioned, you need to serialize (i.e. create a string representation) your table.
For example:
local Data = require( 'Data' )
-- save the content of table 't' to file 't.txt'
Data[ 't.txt' ] = t
-- load the content of file 't.txt' into variable 't'
t = Data[ 't.txt' ]
-- print the content of table 't' as a string
print( Data( t ) )
_[1]={}
_[1]["city"]="São Paulo"
_[1]["country"]="Brazil"
_[2]={}
_[2]["city"]="Napoli"
_[2]["country"]="Italy"
_[3]={}
_[3]["city"]="Nantes"
_[3]["country"]="France"
_[4]={}
_[4]["city"]="Chicago"
_[4]["country"]="United States"
Attachment:
Data.lua
Description: Binary data