# AttributeError: 'unicode' object has no attribute 'data' on Power Table double-click

**URL:** <https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [September 23, 2020, 7:42am UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971 "2020-09-23T07:42:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 23, 2020, 7:42am UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/1 "2020-09-23T07:42:46Z")

</div>

I am trying to edit a Power Table which has been successfully populated with data merged from a couple of CSV files.

```auto
def UpdateParamEditTable():
	import system
	import sys
	
	window = system.gui.getWindow("Main Windows/ParameterEdit")	
	
	# A new recipe or stations selection has been made. Clear the table.
	tbl = window.rootContainer.getComponent('ptblParams') # The Power Table.
	customizer = tbl.columnAttributesData # Save the customizers before we destroy them ...
	# The line above destroys the tblParams customizers which includes the "editable" property of the Setpoint column.
	tbl.columnAttributesData = customizer # This line restores the customizer. 
	rows = [] # Empty.

	# Code to read the CSV file into rows[] goes in here.

	header = ['Line', 'Description', 'Setpoint', 'Min', 'Max'] # Header rows for the table.
	tbl.data = system.dataset.toDataSet(header, rows) # Create the table dataset.
	# This works. The table is populated with the CSV data.

```

So far, so good. The Power Table is populated correctly.

![Ignition Power Table data](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/f/eff5945e4fd48befe0249ee5f75ed2e27e7be317.jpeg)

The Power Table _onDoubleClick_ code starts as follows:

```auto
def onDoubleClick(self, rowIndex, colIndex, colName, value, event):
	# Power Table double-click event.
	table = system.gui.getParentWindow(event).getPathForComponent(self)
	data = system.dataset.toDataSet(table.data) # Line 16.

```

I’m getting an error:

```auto
  File "<extension-method onDoubleClick>", line 16, in onDoubleClick
AttributeError: 'unicode' object has no attribute 'data'

```

which seems to indicate that the system thinks the Power Table is empty when it is clearly well populated. I’ve tried using _system.dataset.toPyDataSet_ but receive the same error.

What am I not understanding here?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 23, 2020, 10:49am UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/2 "2020-09-23T10:49:22Z")

</div>

getPathForComponent() returns a string representing the path to the given component, not the component itself.

There are two functions which are very similar in name but return very different things.

```auto
#signiture for getPathForComponent()
java.lang.String getPathForComponent(java.awt.component c)

#signiture for getComponentForPath()
javax.swing.JComponent getComponentForPath(java.lang.String path)

```

It is not that the system thinks the Power Table is empty but that table is not the object you think it is.

Try the following:

```auto
def onDoubleClick(self, rowIndex, colIndex, colName, value, event):
     # Power Table double-click event
     table = event.source
     data = table.data

```

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [September 23, 2020, 12:31pm UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/3 "2020-09-23T12:31:21Z")

</div>

> [@Transistor](#):
>
> What am I not understanding here?

With extension functions you can access all scripting properties with self.propertyName.

Try changing these two lines:

```auto
table = system.gui.getParentWindow(event).getPathForComponent(self)
data = system.dataset.toDataSet(table.data) # Line 16.

```

to this 1 line:

```auto
data = self.data

```

I see the confusion with trying to use the event parameter because in other cases event is the calling object. I always reference the manual and it looks like the event parameter for the onDoubleClick is the mouse events.

Snippet from the manual:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/00468eb0103d7af2e0e08b6b9f20fd041905b062.png)

Manual link:  
[https://docs.inductiveautomation.com/display/DOC80/Vision+-+Power+Table](https://docs.inductiveautomation.com/display/DOC80/Vision+-+Power+Table)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 23, 2020, 1:17pm UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/4 "2020-09-23T13:17:30Z")

</div>

Psssst!

```auto
    table = self

```

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [September 23, 2020, 3:03pm UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/5 "2020-09-23T15:03:27Z")

</div>

He could use this as per @pturmel suggestion :

```auto
table = self
data = table.data

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 23, 2020, 4:00pm UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/6 "2020-09-23T16:00:26Z")

</div>

@code_skin’s _data = self.data_ worked for me.

Phil’s _table = self_ looks interesting but came in late.

@Irose’s code gave me more attribute errors which I didn’t pursue.

Thank you all. I don’t do enough of this to become proficient and get rather confused sometimes.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 24, 2020, 12:21am UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/7 "2020-09-24T00:21:26Z")

</div>

I was kind’a hinting that the `table` variable wasn’t needed at all…

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [September 24, 2020, 12:21pm UTC](https://forum.inductiveautomation.com/t/attributeerror-unicode-object-has-no-attribute-data-on-power-table-double-click/38971/8 "2020-09-24T12:21:04Z")

</div>

Ahh. That hint went over my head for some reason lol.
