Evaluating Strings

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!

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"

Yes or this:

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

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!