Search code examples
stringcsvluasplit

How to split string values in lua. Error


So I'm trying to split just a string I've read in through a csv file. The string contains several values such as first_name, last_name, email_address, etc... I want to use the split function to assign all those values to my own specific variables. So far this is what I have:

first_name, last_name, email_address, street_address, city, state = split(line, ",")
person_record = {first_name, last_name, email_address, street_address, city, state}

I'm getting an error in lua saying "Attempt to call global 'split' (a nil value)

I've googled with no success on the error message. Do I possibly have to include a library to use the split function????

Or am I just using the split function wrong. Any help is greatly appreciated :/


Solution

  • I don't believe that Lua has a split function as you're trying to use it. This page seems to be a thorough summary of how to split (and join) strings in Lua.