Lua CSV to Table

The code below is a segment from my irrigation controller code. When I use Lua Test and add a few print commands, the pastPrecipTable[day] prints the value from the table, but the local precipForDayOne variable is returning a nil value. Any ideas?

The code is from here: [url=http://forum.micasaverde.com/index.php?topic=24538.0]http://forum.micasaverde.com/index.php?topic=24538.0[/url] and here: [url=https://forum.mysensors.org/uploads/files/1440956563038-pleg-irrigation.pdf]https://forum.mysensors.org/uploads/files/1440956563038-pleg-irrigation.pdf[/url]

[code]–Convert CSV string to a lua table(
function csvToTable(csvString)
local t={}
local i=1

for str in string.gmatch(csvString, “([^, ]+)”) do
t[i] = str
i = i + 1
end

return t
end

–Get past precipitation as CSV string
local pastPrecipCSV = luup.variable_get(RAIN_SID,“PastPrecip”,RAIN_ID)

–Convert CSV string to a lua table
local pastPrecipTable = csvToTable(pastPrecipCSV)

–Number of elements in table
local tableSize = #pastPrecipTable

for day = 1, tableSize do
–Get past precip for each day
local precipForDayOne = pastPrecipTable[day]
end

for day = 2, tableSize do
–Get past precip for each day
local precipForDayTwo = pastPrecipTable[day]
end

luup.variable_set(VAR_SID,“Variable1”,precipForDayOne,VAR_ID)
luup.variable_set(VAR_SID,“Variable2”,precipForDayTwo,VAR_ID)[/code]