lua-users home
lua-l archive

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

Quick and dirty method I use:

     dostring("fields={" .. the_line .. "}")

This will give you a table called fields that contains all the CSV-fields
in the string "the_line". You don't have to care for commas in strings (lua
does this for you) and you automatically get numbers, strings and nil as
appropriate. The index (table key) in "fields" corresponds to the field
position in the line:

     foreachi(fields, print)