Lua中遍历文件操作代码实例

发布时间:2022-04-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Lua中遍历文件操作代码实例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

写的一个关于遍历文件的程序段  记录一下咯

--[[检查所有.txt文件
比如A.txt中第一行规定有20列,但是在X行中多输入一个Tab,则输出:A表的X行填写不规范,行末有多余填写
]]
 
getinfo = io.poPEn('dir ..//file /b /s')
all = getinfo:read('*all')
 
local filenameList = io.open("filename.txt", "wb")
filenameList:wrITe("Path/n")
filenameList:close()
 
filenameList = io.open("filename.txt", "a")
filenameList:write(all)
io.close(filenameList)
io.close(getinfo)
 
 
local filenameList = tab.Open([[../filename.txt]], "Path", false)
 
for index, Row in ipairs(filenameList) do
local pathlist = Row["Path"]
local rowString = string.find(pathlist, ".txt")
if rowString ~= nil and rowString ~="" then
moon.CheckRowlength(pathlist, pathlist)
end
end
 
io.popen('dir /b /s')是windows下的,通过执行命令行dir获得
io.popen('ls')是linux下的

脚本宝典总结

以上是脚本宝典为你收集整理的Lua中遍历文件操作代码实例全部内容,希望文章能够帮你解决Lua中遍历文件操作代码实例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:Lua