How to convert unicode to list

Hi there,

I am facing a strange issue while showing data into a table. See the below table in Column name “Content” I have list of rows,

image

Its going to be huge data in bulk which will be shown here. In short when I press a button with following script

newRow1 = [[1001, 'Tank 1'], [1002, 'Tank 2']]
event.source.parent.getComponent('Seq_Table').data = system.dataset.toDataSet(["Tank IDs","Tank Names"],newRow1)

It works as also the type of newRow1 here is a list. However when I pull the data to add into newRow like below:

Data = system.tag.read("[ProjectName]Global/TankQueued").value #This is same databse linked to the table showen in above pic
pyData = system.dataset.toPyDataSet(Data)
for row in pyData:
	newRow1 = row[1]
	 
print "Value of newRow1",newRow1 #Output is  [[109, u'Tank 9'], [110, u'Tank 10']]
print "Type of New Row 1 is:",type(newRow1) #Output is : <type 'unicode'>

I am not sure why it converts into Unicode. And I did try casting it to List but it didn’t work. My further logic is based on this. Please suggest.

  1. Is it possible to convert that unicode into list
  2. What other way i can achieve this?

below screenshot is just for information:

Ignition version: 8.1
Windows: 10 Pro

ast.literal_eval() can help with that:

import ast

testList = "[[1001, 'Tank 1'], [1002, 'Tank 2']]"
print ast.literal_eval(testList)
3 Likes