07.05.2021, 14:43
This can be used a starting point:
Code:
-- FTP directory absolute path
dir = '/home/ftp/'
-- get file list
files = io.ls(dir)
-- go through all files
for _, file in ipairs(files) do
-- full file path
path = dir .. '/' .. file
-- read file data
data = io.readfile(path)
-- split into lines
lines = data:split('\n')
-- remove CSV header
table.remove(lines, 1)
-- go through all lines
for _, line in ipairs(lines) do
-- split each line into separate values
values = line:trim():split(',')
log(values)
end
-- remove file
os.remove(path)
end