Parsing a table

I have some code that grabs songs from a SQLite table. It returns a table, as you’d expect which looks like the following:

                artist  =       Trapt
                length  =       286
                title   =       Head Strong
                VCode   =       LBeg7CZqSx0
                artist  =       Rise Against
                length  =       254
                title   =       Hero of War
                VCode   =       TdXq20oJlC0
                artist  =       Rise Against
                length  =       226
                title   =       From Heads Unworthy
                VCode   =       CpKGWGqq7OQ

What would be the easiest way of parsing it? I really have no clue, tried a few things but all failed. I’m ideally looking for something that will loop through all the keys and give me row[“artist”] and so on.

I’d do:

for k,v in ipairs(tablehere) do
	local artist = v["artist"]
	local length = v["length"]
	local title = v["title"]
	local vcode = v["vcode"]

That will loop through the table and fetch you the artist, length, etc.

Or if you’re not sure whether you’ll ever add more fields, you could do:

for k,v in pairs(tablehere) do
for k,v in pairs(v) do
– k and v will equal artist and Trapt the first time round, length and 286 the second, etc

Worked this out myself, by simply a numbered loop Songs[1], Songs[2] but this seems better.

Thanks guys.