Hello, I would like to know how do i export alarm journal to CSV.
start = event.source.parent.getComponent('Date Range').startDate
end = event.source.parent.getComponent('Date Range').endDate
journal = system.alarm.queryJournal(startDate=start, endDate=end).getDataset()
filePath = system.dataset.exportExcel("Journal.xls", 1, journal)
if filePath != None:
system.net.openURL("file://"+filePath)
Sorry, you said CSV, not excel…
start = event.source.parent.getComponent('Date Range').startDate
end = event.source.parent.getComponent('Date Range').endDate
journal = system.alarm.queryJournal(startDate=start, endDate=end).getDataset()
csv = system.dataset.toCSV(journal)
filePath = system.file.saveFile("mycsv.csv", "csv", "CSV File")
if filePath:
system.file.writeFile(filePath, csv)
Thank you so much for your help.
hi Jonathan, its working but when i export the alarm journal only “EventId”, “Source”, “DisplayPath”, “EventTime”, “EventState”, “Priority”, “IsSystemEvent” are coming. how can i manage these columns. i also want to export “Label”.
Thanks in advance.
hi did you solve this problem? this is my current problem right now
Hi Daren,
As I understand you want to see data that is not directly in the table like me. So I used the following code for this;
from com.inductiveautomation.ignition.common.config import BasicProperty
eventTime = BasicProperty("eventTime", BasicProperty().getType())
start = event.source.parent.getComponent('Alarm Journal').startDate
end = event.source.parent.getComponent('Alarm Journal').endDate
alarms = system.alarm.queryJournal(startDate=start, endDate=end)
headers = ["EventTime", "Label", "DiplayPath", "SourcePath","Priority"]
data = []
for alarm in alarms:
data.append([alarm.get(eventTime),alarm.getLabel(), alarm.getDisplayPath(), alarm.getSource(), alarm.getPriority()])
val = system.dataset.toDataSet(headers, data)
filePath = system.dataset.exportExcel("AlarmJournal", 1, val)
if filePath != None:
system.net.openURL("file://"+filePath)
the important point here is “system.alarm.queryJournal()”
For detailed information about this command;
https://docs.inductiveautomation.com/display/DOC81/system.alarm.queryJournal
Hi to All,
I want to export a csv file through a component of BUTTON from the Alarm Journal, I did it using this script:
dataset = event.source.parent.getComponent(‘Alarm Journal’).getAlarms()
file = system.date.now() **
path = system.dataset.exportCSV(“data.csv”, 1, dataset)
if path != None:
** system.net.openURL(“file://”+path)
…unfortunately, I’m not satisfied because the result (csv file) is lack of information, the event time is incomplete, I want to include the Date and there are missing columns when it exported. How can I solve this one?
Any ideas?
Posting the same question in multiple topics is against this forum's rules. You posted this over here:
noted sir, thank you