Lua中遍歷文件操作代碼實(shí)例
更新時(shí)間:2015年05月05日 09:15:32 投稿:junjie
這篇文章主要介紹了Lua中遍歷文件操作代碼實(shí)例,本文直接給出示例代碼,需要的朋友可以參考下
寫的一個(gè)關(guān)于遍歷文件的程序段 記錄一下咯
--[[檢查所有.txt文件 比如A.txt中第一行規(guī)定有20列,但是在X行中多輸入一個(gè)Tab,則輸出:A表的X行填寫不規(guī)范,行末有多余填寫 ]] 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下的,通過執(zhí)行命令行dir獲得 io.popen('ls')是linux下的
您可能感興趣的文章:
相關(guān)文章
Openresty服務(wù)器使用lua腳本寫的Hello World簡(jiǎn)單實(shí)例
這篇文章主要介紹了Openresty服務(wù)器使用lua腳本寫的Hello World簡(jiǎn)單實(shí)例,OpenResty (也稱為 ngx_openresty)是一個(gè)全功能的 Web 應(yīng)用服務(wù)器。它打包了標(biāo)準(zhǔn)的 Nginx 核心,很多的常用的第三方模塊,以及它們的大多數(shù)依賴項(xiàng),需要的朋友可以參考下2015-04-04