This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read CSV file from LM/SL FTP device folder and put data to groups
#4
1. If the script is working properly then you should have only one file before it runs. Since you have meter values that cannot become smaller you can check if the current object value is smaller than the new value before writing:
Code:
value = tonumber(...)
addr = ...
if value and value > grp.getvalue(addr) then
  grp.write(addr, value)
end

2. size, mtime = io.stat(path) where mtime is file modification timestamp, it can be converted to any date/time format using os.date(fmt, mtime)

3. You need to add grp.write() calls yourself after values = line:trim():split(','), values[1] is the first CSV row entry, values[2] is the second and so on

4. Each os.remove(path) removes a single file, path variable already contains full path (dir .. '/' .. file)

5. There's no defined order, you can add table.sort(files) after files = io.ls(dir) to sort the files table before going through all files
Reply


Messages In This Thread
RE: Read CSV file from LM/SL FTP device folder and put data to groups - by admin - 09.05.2021, 09:30

Forum Jump: