标签:blog io 文件 for div cti log line
创建Lua函数载入CSV文件并保存到表中的函数:
function GetLines(fileName) indx = 0 myLines ={} for line in io.line(string.format("%s%s", "c:/lua_scripts/",filename)) do indx = indx + 1 myLines[indx] = line end return indx, myLines --returns number of lines and line table end function GetValues(myString) num = 0 values = {} if myString ~= nil then while string.find(myString, ",") ~= nil do i, j =string.find(myString, ","); num =num + 1; values[num] = string.sub(myString, 1, j-1); myString = string.sub(myString, j+1, string.len(myString)) end num = num + 1 values[num] = myString end return num, values end
Lua读取CSV文件到table中,布布扣,bubuko.com
标签:blog io 文件 for div cti log line
原文地址:http://www.cnblogs.com/xxiaoye/p/3925608.html