# Evaluating Strings

**URL:** <https://forum.inductiveautomation.com/t/evaluating-strings/10300>\
**Category:** Ignition\
**Created:** [July 31, 2015, 6:47pm UTC](https://forum.inductiveautomation.com/t/evaluating-strings/10300 "2015-07-31T18:47:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanG](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@RyanG](https://forum.inductiveautomation.com/u/RyanG)\
**Post date:** [July 31, 2015, 6:47pm UTC](https://forum.inductiveautomation.com/t/evaluating-strings/10300/1 "2015-07-31T18:47:08Z")

</div>

So I’m trying to write the following script to check if a Table contains no data:

x = str(event.source.parent.getComponent(‘Table 1’).data)  
y = ‘Dataset [0R ⅹ 2C]’  
if x == y:  
print “Works”  
else:  
print “Doesn’t Work”

But even though the x and y equal exactly the same thing it still doesn’t execute correctly and prints “Doesn’t Work”. Any Idea what I’m doing wrong? Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [July 31, 2015, 7:55pm UTC](https://forum.inductiveautomation.com/t/evaluating-strings/10300/2 "2015-07-31T19:55:33Z")

</div>

Instead of trying to compare strings like that, just convert the data to a pyData set and look at the length. That is a better way of doing it anyway. Try something like this:

`
tableData = event.source.parent.getComponent('Table 1').data
pyData = system.dataset.toPyDataSet(tableData)
if len(pyData) > 0:
	print "Data Exists"
else:
	print "Table Empty"`

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 3, 2015, 6:32am UTC](https://forum.inductiveautomation.com/t/evaluating-strings/10300/3 "2015-08-03T06:32:51Z")

</div>

Yes or this:

```auto
if event.source.parent.getComponent('Table').data.rowCount > 0:
	print "data exists"
else:
	print "data does not exist"
```

---

<div class="post-metadata">

**Author:** ![RyanG](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@RyanG](https://forum.inductiveautomation.com/u/RyanG)\
**Post date:** [August 3, 2015, 1:21pm UTC](https://forum.inductiveautomation.com/t/evaluating-strings/10300/4 "2015-08-03T13:21:50Z")

</div>

Thank you both of those work! I was looking for such a thing that would allow me to count the rows but couldn’t find it. Thank you!
