Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua - convert a table into a comma separated list

Tags:

csv

lua

lua-table

I need to convert a table into a comma separated list in order to save it to a text file. Is there a built in method for doing this in Lua?

like image 706
clua7 Avatar asked Jul 05 '11 22:07

clua7


2 Answers

If your table is an array, you can use table.concat to print CSVs:

t={10,20,30}
print(table.concat(t,","))

outputs 10,20,30.

like image 102
lhf Avatar answered Sep 20 '22 01:09

lhf


There isn't a built in function, but there are examples onthe web.

This is a decent one actually.

like image 28
Alan Avatar answered Sep 22 '22 01:09

Alan