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.

script for writing in to csv files in a specific position
#1
Hello All,
I am using 17 event scripts to get specific information from users for customer satisfaction in a system.

If the users set in a specific event it should register its value in a specific position in a CSV file. But I have two questions;

1- How can I write a script that will get input from an event and write it in a specific position in a CSV files 
2- How can I write a script that will be able to calculate the total number of event input that was written into the CSV files 

Thanks.

The event script is;

if grp.getvalue('1/1/134') == true then
 
grp.write('13/2/6',true)
 
  grp.write('1/1/147',grp.getvalue('1/1/147')+1)
  grp.write('1/1/158',grp.getvalue('1/1/158')+1)
 
    ---------------- script alarme intrusion ----------------
os.execute('mkdir -p /home/ftp/Rapport_SatCl/Jour')
---------------writing to file--------------------------------
local pile = io.open('/home/ftp/Rapport_SatCl/Jour/Rapport_SatCl_Jour_'..os.date('%d%B%Y')..'.csv',"a")
pile:write(os.date('%d/%m/%Y').." "..tostring(os.date('%H:%M:%S'))) pile:write(";")
  pile:write(";")
  pile:write("1")
pile:close()
 
 
end
Reply
#2
By writing to FTP you are writing to SD card and you will brake it at some point with such solution.
Why don't you just log some objects and then you can export object log to CSV, There are examples how to on this forum.
Object log will save info of which user changed the value.
------------------------------
Ctrl+F5
Reply
#3
There's also an option to use storage for custom text events: https://forum.logicmachine.net/showthread.php?tid=350
Reply


Forum Jump: