# Export data to excel cyclically

**URL:** <https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565>\
**Category:** Ignition\
**Created:** [June 13, 2014, 2:19pm UTC](https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565 "2014-06-13T14:19:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![controlsim](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@controlsim](https://forum.inductiveautomation.com/u/controlsim)\
**Post date:** [June 13, 2014, 2:19pm UTC](https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565/1 "2014-06-13T14:19:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [June 16, 2014, 8:56pm UTC](https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565/2 "2014-06-16T20:56:31Z")

</div>

Try instead [system.dataset.toCSV](http://inductiveautomation.com/support/usermanuals/ignition/system_dataset_tocsv.htm).

---

<div class="post-metadata">

**Author:** ![controlsim](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@controlsim](https://forum.inductiveautomation.com/u/controlsim)\
**Post date:** [June 16, 2014, 10:00pm UTC](https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565/3 "2014-06-16T22:00:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 16, 2014, 10:22pm UTC](https://forum.inductiveautomation.com/t/export-data-to-excel-cyclically/8565/4 "2014-06-16T22:22:19Z")

</div>

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)
`
