Logic Machine Forum
script for writing in to csv files in a specific position - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: script for writing in to csv files in a specific position (/showthread.php?tid=4635)



script for writing in to csv files in a specific position - yaya mounjouonpou - 09.03.2023

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


RE: script for writing in to csv files in a specific position - Daniel - 09.03.2023

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.


RE: script for writing in to csv files in a specific position - admin - 09.03.2023

There's also an option to use storage for custom text events: https://forum.logicmachine.net/showthread.php?tid=350