# Parsing an arrow symbol into table header

**URL:** <https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 31, 2022, 6:49pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651 "2022-08-31T18:49:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel\_Wolf](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@Nathaniel\_Wolf](https://forum.inductiveautomation.com/u/Nathaniel_Wolf)\
**Post date:** [August 31, 2022, 6:49pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651/1 "2022-08-31T18:49:53Z")

</div>

I attempting to parse an arrow into the header of a power table. The console output shows the correct symbol but I get accented characters instead.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4aa334e0c736a9416e2beacdebce41e02e577663.png)

Here is a custom function that returns a symbol to be append to the custom header.

```auto
def goalSymbol(self, goal):
	"""
	Arguments:
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
	"""

	up = u'\u2191' # up arrow
	down = u'\u2193' # down arrow
	print up
	print down
	
	if goal == "eq":
		return "="
	elif goal == "gt":
		return "{}".format(up)
	elif goal == "gte":
		return "{}=".format(up)
	elif goal == "lt":
		return "{}".format(down)
	elif goal == "lte":
		return "{}=".format(down)
	else:
		return "RA"

```

And here is some brief context of how that function is invoked, not shown is the append dataset functionality which does work. can show the entirety of the codeblock as well (part of the Initialize extension method) upon request.

```auto
	goal = kpi_collection['goal']
	target = "Target{}".format(self.goalSymbol(goal))
	headers = ["Unit",target,"Actual"]

```

---

<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:** [August 31, 2022, 7:04pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651/2 "2022-08-31T19:04:43Z")

</div>

Add u’ to the front of the symbol, but actually put the symbol in.

`u'↑`

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 31, 2022, 7:19pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651/3 "2022-08-31T19:19:41Z")

</div>

a ‘u’ in front of “Target” should be enough.

Edit. Actually, that’s not quite right, You’ll need to specify unicode for everything if you keep it like this. The curly brace formatting does funky things when parsing.

```python
	if goal == "eq":
		return "="
	elif goal == "gt":
		return u"{}".format(up)
	elif goal == "gte":
		return u"{}=".format(up)
	elif goal == "lt":
		return u"{}".format(down)
	elif goal == "lte":
		return u"{}=".format(down)
	else:
		return "RA"

```

```python
target = u"Target{}".format(self.goalSymbol(goal))
```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 31, 2022, 7:49pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651/4 "2022-08-31T19:49:29Z")

</div>

A more concise approach:

```python
def goalSymbol(goal):
	up = u'\u2191' # up arrow
	down = u'\u2193' # down arrow

	symbolMap = {
		'eq': '=',
		'gt': up,
		'gte': up + '=',
		'lt': down,
		'lte': down + '='
	}

	return symbolMap.get(goal, "RA")	

```

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Wolf](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@Nathaniel\_Wolf](https://forum.inductiveautomation.com/u/Nathaniel_Wolf)\
**Post date:** [August 31, 2022, 8:39pm UTC](https://forum.inductiveautomation.com/t/parsing-an-arrow-symbol-into-table-header/63651/5 "2022-08-31T20:39:51Z")

</div>

@JordanCClark Thanks that worked!

@paul-griffith Thank you, that does look a lot cleaner. I was going to use pattern matching but given this is Python 2.0 I assumed that wouldn’t work.
