06.02.2019, 21:51
I have script, bun I need to select values in two different group address ranges. From 1 to 15 and from 20 to 30.
I need get the values in one csv file.
rows = {}
-- from 3/0/1 to 3/0/30
addrstart = 1
addrend = 190
rows[ #rows + 1 ] = 'name,actual_value,start_month,current_month,previous_month'
for i = addrstart, addrend do
actual_value_obj = grp.find('3/1/' .. i)
name = actual_value_obj.name
actual_value = actual_value_obj.value
start_month = grp.getvalue('2/1/' .. i)
current_month = grp.getvalue('4/1/' .. i)
previous_month = grp.getvalue('1/1/' .. i)
rows[ #rows + 1 ] = name .. ',' .. actual_value .. ',' .. start_month .. ',' .. current_month .. ',' .. previous_month
end
--csv = table.concat(rows, '\r\n')
csv = string.char(0xEF, 0xBB, 0xBF) .. table.concat(rows, '\r\n')
-- read csv report file
--data = storage.get('csv')
to1 = grp.getvalue('7/7/2')
to2 = grp.getvalue('7/7/7')
date = os.date('%Y-%m-%d')
-- send file as report.csv with text/csv mime type
res, err = mailattach('Atskaite par tekoso menesi', 'CSV file attached', 'report-1-90' .. date .. '.csv', csv, 'text/csv')
I need get the values in one csv file.
rows = {}
-- from 3/0/1 to 3/0/30
addrstart = 1
addrend = 190
rows[ #rows + 1 ] = 'name,actual_value,start_month,current_month,previous_month'
for i = addrstart, addrend do
actual_value_obj = grp.find('3/1/' .. i)
name = actual_value_obj.name
actual_value = actual_value_obj.value
start_month = grp.getvalue('2/1/' .. i)
current_month = grp.getvalue('4/1/' .. i)
previous_month = grp.getvalue('1/1/' .. i)
rows[ #rows + 1 ] = name .. ',' .. actual_value .. ',' .. start_month .. ',' .. current_month .. ',' .. previous_month
end
--csv = table.concat(rows, '\r\n')
csv = string.char(0xEF, 0xBB, 0xBF) .. table.concat(rows, '\r\n')
-- read csv report file
--data = storage.get('csv')
to1 = grp.getvalue('7/7/2')
to2 = grp.getvalue('7/7/7')
date = os.date('%Y-%m-%d')
-- send file as report.csv with text/csv mime type
res, err = mailattach('Atskaite par tekoso menesi', 'CSV file attached', 'report-1-90' .. date .. '.csv', csv, 'text/csv')