# Append Special character string to list

**URL:** <https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274>\
**Category:** Ignition\
**Created:** [September 20, 2022, 12:36pm UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274 "2022-09-20T12:36:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 20, 2022, 12:36pm UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/1 "2022-09-20T12:36:48Z")

</div>

Hi i have unicode type characters

`a = "épaisseur4/nominalvalue"`

when append this to a lits i am getting like this

```auto
final = []
final.append(a)
print final

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/87bf29dd3d5ddf2e0dec5ea2e12cd065920f3674.png)

any way to fix this ?

---

<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 20, 2022, 1:43pm UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/2 "2022-09-20T13:43:49Z")

</div>

```auto
a = "épaisseur4/nominalvalue"
final = []
final.append(a)
print final
print final[0]

```

returns

```auto
['\xc3\xa9paisseur4/nominalvalue']
épaisseur4/nominalvalue
>>> 

```

Does that get what you want? When you reference the string item it gets decoded properly.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 20, 2022, 1:58pm UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/3 "2022-09-20T13:58:24Z")

</div>

There's nothing to fix.  
When you print an array, it will print the `repr()` of its elements. Which gives you that character code.

If you want to display the string representation instead, you can print them separately.  
Or make your own list-type :

```python
class Array(list):
	def __str__ (self):
		elements_string = ', '.join(self)
		return "[{}]".format(elements_string)

print Array(final)
print final

```

> [épaisseur4/nominalvalue]  
> ['\xc3\xa9paisseur4/nominalvalue']

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 21, 2022, 5:07am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/4 "2022-09-21T05:07:01Z")

</div>

> [@pascal.fragnoud](#):
>
> `list`

How to pass Array(final) to a dataset?

when i pass this to dataset i am getting same errror

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25d05055b030ec7d59a8f69dcea50051220eda1a.png)

code i am using

`event.source.parent.getComponent('Power Table').data = system.dataset.toDataSet(['Path'], [[x] for x in Array(final)])`

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 21, 2022, 5:44am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/5 "2022-09-21T05:44:37Z")

</div>

I’ve set up an experiment transferring information from one power table to another in an effort to replicate your issue, but haven’t been successful.

Here is the script I used on a button:

```auto
class Array(list):
	def __str__ (self):
		elements_string = ', '.join(self)
		return "[{}]".format(elements_string)
final = []
dataSet = event.source.parent.getComponent('Power Table 1').data
for row in range(dataSet.rowCount):
	final.append(dataSet.getValueAt(row, "Path"))
event.source.parent.getComponent('Power Table').data = system.dataset.toDataSet(['Path'], [[x] for x in Array(final)])

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/5/e551f41b7019c2015aee62f9c2c5d194c2efda06.png)

When I push the button, I get this result:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2c0883f3e1169ee3d429b840124e9d0841442e4e.png)

The array transfers correctly, so I’m not sure what the issue is. What is your input and expected result? Perhaps, I can adjust the experiment and help you figure this out.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [September 21, 2022, 5:59am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/6 "2022-09-21T05:59:09Z")

</div>

> [@justinedwards.jle](#):
>
> `system.dataset.toDataSet`

I found the issue while appending to the list i need to do like this

```auto

final.append(unicode(tags))
```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2022, 7:52am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/7 "2022-09-21T07:52:21Z")

</div>

If you’re going to iterate over the array, then there’s no point in having a custom class.  
The whole point of it is to override the ` __str__ ` method, which is only callable on the array itself.  
The elements you get when iterating are the same you’d get from a builtin python list.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2022, 8:39am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/8 "2022-09-21T08:39:45Z")

</div>

I took the liberty of cleaning up the script a bit:

```python
input_table = event.source.parent.getComponent('Power Table 1')
output_table = event.source.parent.getComponent('Power Table')

paths = input_table.data.getColumnAsList(x) # where x is the 0 based index of the column
output_table.data = system.dataset.toDataSet(['Path'], [[unicode(p)] for p in paths])

```

Two things to note:

- I don’t use vision, so I can’t test this in real conditions
- Why isn’t this a binding on `Power Table` ?

edit: I don’t think the explicit unicode conversion is actually needed there, but I have no idea how vision tables treat things… I’d try without it first if I were you.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 21, 2022, 9:05am UTC](https://forum.inductiveautomation.com/t/append-special-character-string-to-list/64274/9 "2022-09-21T09:05:18Z")

</div>

> [@pascal.fragnoud](#):
>
> I don’t use vision, so I can’t test this in real conditions

Your code is perfect, and will work just fine in Vision as long as x is correctly defined.
