lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jan 25, 2012 at 07:21, Sandeep Ghai <sandeep.ghai92@gmail.com> wrote:
> Hello everyone,
> I am doing file handling using Lua programming. But I need some help where I
> got stuck.
> I want to read particular line from the file.
> consider the following file:-
>
> problem description
> title="3d Beam Sample Problem (Logan ex. 6.8, p.248)" nodes=4 elements=3
>
> nodes
> 1 x=0   y=0        constraint=fixed
> 2 x=0   y=120    constraint=free    force=side_sway
> 3 x=120 y=120                              force=twist
> 4 x=120 y=0       constraint=fixed
>
> beam elements
> 1 nodes=[1,2] material=column
> 2 nodes=[2,3] material=beam
> 3 nodes=[3,4] material=column
>
>
> I want to read 'x',and 'y' values whenever I pass argument to read 'nodes'
> and similarly for other contents(like constraint,forces etc) too.
> After then I want to pass all these things directly into database,to gather
> all the similar things from number of files.
> Please help me in syntax. I am a beginner in Lua Programming.
> Thank you in advance.
>
>
> --
> Sandeep Ghai
> blog: http://sandeepghai.wordpress.com
>

So, where did you get stuck? It looks like mostly a matter of clever
string.gsub use. LPEG or a string.split function might also help.

-- 
Sent from my toaster.