# Clearing a dataset?

**URL:** <https://forum.inductiveautomation.com/t/clearing-a-dataset/6354>\
**Category:** Ignition\
**Created:** [April 30, 2013, 10:28pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354 "2013-04-30T22:28:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [April 30, 2013, 10:28pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/1 "2013-04-30T22:28:22Z")

</div>

I am creating a dataset to display information in a table. When i am done, i would like to clear or delete all rows in the dataset. what is the best way to do this?  
I can use system.dataset.deleteRow() but then i need to know how many rows are in the dataset and i can’t figure out how to get that either?  
Thanks for the help.  
Scott

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 30, 2013, 10:42pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/2 "2013-04-30T22:42:23Z")

</div>

Do you really need to clear the dataset or can you just set the tables data property to a new empty dataset?

---

<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:** [April 30, 2013, 11:01pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/3 "2013-04-30T23:01:25Z")

</div>

As Kevin suggests, it looks like the dataset clears itself (after populating the table.data) so there is no need to “clear” the dataset. Nonetheless, if you need the number of records in the dataset you can use the len function after converting to a PyDataSet:

```auto
numOfRecords = len(system.dataset.toPyDataSet(table.data))
```

…or you could clear the table by creating a “blank” dataset:

```auto
blankHeader = []
blankDataSet = []
table.data = system.dataset.toDataSet(blankHeader, blankDataSet)
```

This is all based on Ignition 7.5.6.

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [April 30, 2013, 11:22pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/4 "2013-04-30T23:22:36Z")

</div>

Thanks, both are useful.  
I have another question regarding populating the table (dataset).  
I have a bunch of tags in various folders, the tags are simply numbered 1, 2, … 60, etc. Not all folders have all 60 tags.  
Currently i pass the folder path and then loop through the 60 possible tag names and add it to the table if the tag exists. This works but is very slow, i assume due to the use of .TagExists function.  
Can you suggest a better way to populate a table with all tags in a folder?  
Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 1, 2013, 1:20am UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/5 "2013-05-01T01:20:35Z")

</div>

how about using system.tag.readAll? save all of your folder names in a database table, then write a script that will generate all of the possible tagnames and put them into a string sequence. from there run something like this\*\*\* I reread your post and I cant tell if you wanted to just check the tags in 1 folder or in every folder in your system. If you just want 1 folder it would be even easier, you wouldnt need to have the folders in the database at all.\*\*\*

[code]  
tags = [“test”, “test1”, “test123”]

values = system.tag.readAll(tags)

for x in range(len(tags)):

print “%s = %s” % (tags[x], values[x])[/code]

and it will give you this

```auto
test = [false,Good]
test1 = [100000,Good]
test123 = [NULL,Not Found]
```

you can then loop thru and dump anything that is “Not Found” and then send the tagpaths to your dataset. I havent used the tagexists function but my guess is that it calls each tag individually, which is the reason it takes so long.

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [May 1, 2013, 9:02pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/6 "2013-05-01T21:02:24Z")

</div>

Thanks for the good suggestion, it does work better and i am going to use it but unfortunately still does work that well (still slow) only because not only do i need the tag value but i also need its .AlertDisplayPath. i need this information to describe the point to the user as the path really does not mean much to them.  
the only way i know to get the alertDisplayPath is:  
system.tag.getTagValue(tags[x] + “.AlertDisplayPath”)

once i add that line of code the update goes from immediate to several seconds, still better than using the tagexists function which was several seconds x 2!

Still open to any other suggestions.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 1, 2013, 10:52pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/7 "2013-05-01T22:52:06Z")

</div>

[quote=“scott\_rister”]Thanks for the good suggestion, it does work better and i am going to use it but unfortunately still does work that well (still slow) only because not only do i need the tag value but i also need its .AlertDisplayPath. i need this information to describe the point to the user as the path really does not mean much to them.  
the only way i know to get the alertDisplayPath is:  
system.tag.getTagValue(tags[x] + “.AlertDisplayPath”)

once i add that line of code the update goes from immediate to several seconds, still better than using the tagexists function which was several seconds x 2!

Still open to any other sug[/quote]

yes you would want to look at using system.tag.getTagValues or system.tag.readAll. if you use system.tag.getTagValue it will make a call for each tag, which if I remember right takes about 60 ms per tag. if you use 1 of the 2 that I mentioned it will pull all of the tags in 1 call. its pretty extraordinary. Ill try to remember to throw you a few examples of using those scripts.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 2, 2013, 5:47pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/8 "2013-05-02T17:47:12Z")

</div>

try something like this

```auto
query = "select displayname, devicename FROM junk"
if event.propertyName in ["devices", "refresh"]:

   newData = []
   header = ["Displayname", "Devicename", "tag1", "tag2", "tag3", "tag4", "tag5"]
   res = system.db.runQuery(query)
   tagPaths = []

   for row in res:
       tagPath = row[1]
   
  	  
       tagPaths.append("%s/tag1"%tagPath)
       tagPaths.append("%s/tag2"%tagPath)
       tagPaths.append("%s/tag3"%tagPath)
       tagPaths.append("%s/tag4"%tagPath)
       tagPaths.append("%s/tag5"%tagPath)
	   

            
   results = system.tag.getTagValues(tagPaths)
   
   idx = 0
   for row in res:
       displayName = row[0]
       tagPath = row[1]
       newData.append([displayName, tagPath, results[0+idx], results[1+idx], results[2+idx], results[3+idx], results[4+idx]])
       idx += 5

system.gui.getParentWindow(event).getComponentForPath('Root Container.Table').data = system.dataset.toDataSet(header, newData)
```

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [October 29, 2021, 1:34pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/9 "2021-10-29T13:34:52Z")

</div>

I want to display a message when no data on table component, something like below but it’s not working, plz let me know how to mention for table if nodata

```auto
if (LotId!="" or MatlAutoId!=None) and vtable==dataset[0x6]:
		self.props.emptyMessage.noData.text="No Data Found"
		self.props.emptyMessage.noData.icon.path=material/sentiment_very_dissatisfied
	else:
		pass

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 29, 2021, 2:38pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/10 "2021-10-29T14:38:34Z")

</div>

Split this topic on October 29, 2021, 2:38pm UTC

4 posts were merged into an existing topic: [Display custom message when Perspective Table has no data](https://forum.inductiveautomation.com/t/display-custom-message-when-perspective-table-has-no-data/52499/3)

---

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [January 16, 2024, 9:46pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/11 "2024-01-16T21:46:35Z")

</div>

Great way and more readable. I just did this due how easily it was to implement. Thanks for your input!

```auto
	# clear table and wait 1 second, to show user things are happening
	self.getSibling("RandomTagTableName").props.data = ""
	time.sleep(1)

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 16, 2024, 10:58pm UTC](https://forum.inductiveautomation.com/t/clearing-a-dataset/6354/12 "2024-01-16T22:58:15Z")

</div>

> [@jacque\_trahan](#):
>
> `time.sleep(1)`

This is the opposite of showing a user things are happening.  
Consider toggling the visibility of an icon, and/ or animating it with CSS so that the page conveys action instead of appearing to be frozen with data suddenly missing.
