24.11.2020, 09:09
(24.11.2020, 07:34)admin Wrote: .lp file is not a script, it's a Lua file that only the web server can run. It should be uploaded via FTP to the user directory using apps username. If the file is named csv.lp then the URL will be http://LM_IP/user/csv.lp
Code:
<?
-- set headers for csv file download
setdlheader('text/csv; charset=utf-8', 'report', 'csv')
-- generate csv here
value=grp.tag("consumption")
filename = string.format('consumption.csv', os.date('%d-%m-%Y-%H-%M'))
a={}
for index, id in ipairs(value) do
name=id["name"]
meter=id["data"]
consumption=name .."," .. meter
a[index]=consumi
log(a)
end
csv = a
result, err = io.writefile (filename, csv)
-- output to the user
print(csv)
I generate file as above without success. Is it correct the procedure? Thanks.