Export data to excel cyclically

Hello, a customer is asking me to export data to excel or txt file cyclically every few hours or days.

I am trying to create a code to export data from a table to a excel or txt file. With this code works:

table = event.source.parent.getComponent("Table") filePath = system.dataset.exportExcel("data.xls", 1, table.data) if filePath != None: system.net.openURL("file://"+filePath)

but what I’m trying to do is that when I use this code again don’t generate me a new excel file, I need to use the same file to add more data to it and if possible go deleting the oldest data cyclically every few hours or days.

Try instead system.dataset.toCSV.

thanks adamaustin that works, I wondering if is possible to write a dataset with one column to a txt file, just the values.

Yes it is possible. Here is an example of what I think you are after:

file = system.file.saveFile("test.txt") if file: data = system.tag.read("[Client]Some Tag").value for row in range(data.rowCount): text = "" for column in range(data.columnCount): text+=str(data.getValueAt(row,column)) text+="," text = text[:-1] + "\n" system.file.writeFile(file,text,True)

1 Like