-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathluaParserBigFile.lua
More file actions
64 lines (46 loc) · 1.26 KB
/
Copy pathluaParserBigFile.lua
File metadata and controls
64 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
string.split = function(str, pattern)
pattern = pattern or "[^%s]+"
if pattern:len() == 0 then pattern = "[^%s]+" end
local parts = {__index = table.insert}
setmetatable(parts, parts)
str:gsub(pattern, parts)
setmetatable(parts, nil)
parts.__index = nil
return parts
end
local pubs = {}
local lineNum = 0
local
function loadBigData()
local path = script.path .. "/iv04/additional/tableform_data/"
print("path ", path)
local fileN = "Big_data.txt"
local fname = LuaAV.findfileinpath(path, fileN, true)
local f = io.open(fname, "r")
print("fio: ?? ", f)
if f then
print("file open")
for line in f:lines() do
lineNum = lineNum + 1
local parts = line:split( "[^,\t]+" )
pubs[lineNum] = {parts[1], parts[2], parts[3], parts[4]}
--print(parts[3], parts[4])
end
end
f:close()
end
loadBigData()
local
function saveArticles()
local path = script.path .. "/iv04/additional/tableform_data/"
local fileN = "articlesInfo.txt"
local fname = LuaAV.findfileinpath(path, fileN, true)
local f = io.open(fname, "w")
print("fio write: ", f)
for l=1, lineNum do
local p = pubs[l]
f:write(l,"\t", p[1],"\t", p[2],"\t", p[3],"\t", p[4],"\n")
end
f:close()
end
saveArticles()