Logic Machine Forum
CSV manage - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: CSV manage (/showthread.php?tid=2560)



CSV manage - toujour - 02.04.2020

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


RE: CSV manage - admin - 02.04.2020

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