This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

CSV manage
#1
Hi Guys,

I have a string form a CSV wiht more lines and about 20 values for every lines.

What is the better way to access every single elements ?

For examples:
I want the third element of row 3 ( similar at an 2D array )

I'm working on learning the list/dict/table functions   At .

Any help is appreciated !!

Thanks
KNX Advanced Partner + Tutor
Reply
#2
Use string.split:
Code:
csv = [["aaa",123,1,4
"bbb",456,2,5
"ccc",789,3,6]]

rows = csv:split('\n')
for _, row in ipairs(rows) do
  items = row:split(',')
  log(items)
end
Reply


Forum Jump: