[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Saving a table in file
- From: "Luciano de Souza" <luchyanus@...>
- Date: Sun, 7 Mar 2010 19:20:09 -0300
Wonderful! It's really wonderful. When I mentioned I would like something
really simple, I could not imagine how simple it would be! With Data e Json,
I could do everything I wanted.
I always admire Python for the simpliicity. For the same reason, I admire
Lua. I have started in Lua because of IUP. Now I can't imagine to adopt
another language.
A gift... What you sent me was a gift.
There is choices more complicated, adopted by people I respect. But I am
sure that for my simple needs, Data and Json are perfect. Both are excelent.
Thank you!
----- Original Message -----
From: "Petite Abeille" <petite.abeille@gmail.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Sunday, March 07, 2010 5:54 PM
Subject: Re: Saving a table in file
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"
--------------------------------------------------------------------------------