# Issue in split list

**URL:** <https://forum.inductiveautomation.com/t/issue-in-split-list/43628>\
**Category:** Ignition\
**Created:** [February 19, 2021, 4:36pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628 "2021-02-19T16:36:50Z")\
**Posts on this page:** 20\
**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:** [February 19, 2021, 4:36pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/1 "2021-02-19T16:36:50Z")

</div>

**[u’BP Compressors’, u’SPA Compressors’]**

i need to remove **u** from the list . please let me know how to remove the **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:** [February 19, 2021, 4:41pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/2 "2021-02-19T16:41:25Z")

</div>

The u just means it’s unicode. It’s not part of the string itself.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/3935abef5bd85b86a5b9c65439788d3f6c6c0a8f.png)

---

<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:** [February 19, 2021, 4:43pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/3 "2021-02-19T16:43:55Z")

</div>

i need to pass that value to **dataset header**  
[“BP compressors”, “SPA Compressors”]  
how to pass like this?  
please let me know how to pass this words to header

---

<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:** [February 19, 2021, 4:48pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/4 "2021-02-19T16:48:58Z")

</div>

I have not had an issue using unicode strings as headers. 🤷‍♂️

But, if you really need to make sure they’re string objects:

```python
listIn = [u'BP Compressors', u'SPA Compressors']
listOut = [str(i) for i in listIn]
```

---

<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:** [February 19, 2021, 4:49pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/5 "2021-02-19T16:49:42Z")

</div>

Out of curiosity, where is the list coming from?

---

<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:** [February 19, 2021, 4:55pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/6 "2021-02-19T16:55:40Z")

</div>

> [@JordanCClark](#):
>
> listIn = [u'BP Compressors', u'SPA Compressors'] listOut = [str(i) for i in listIn]

i am browsing UDT tag folders for Stacked bar. i need to use folders name as header for dataset of bar

---

<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:** [February 19, 2021, 5:03pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/7 "2021-02-19T17:03:49Z")

</div>

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

i am getting like this when i pass this to header? whats wrong in this?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 19, 2021, 5:04pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/8 "2021-02-19T17:04:35Z")

</div>

Show us the code.

---

<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:** [February 19, 2021, 5:05pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/9 "2021-02-19T17:05:04Z")

</div>

```auto
excl= ["Device Info"]
name = "Compressors"
temp =[]
tagstatus = []
test = []
viru = []
#dt = Total_Consumption
def browse(path, filter):
		results = system.tag.browse(path, filter)
		return results
	
res = browse('[MQTT Engine]Edge Nodes/Robertsbridge/Energy/Electric/Compressors',{'tagType': 'Folder'})
#print res
for result in res.getResults():
		if result.get("name") not in excl:
			temp.append(result.get("name"))
			#print temp
			path = browse(result.get("fullPath"),{'tagType': 'UdtInstance'})
			#print result['name']
			x = result['name']
			viru.append(x)
			#t = a.split()
			#print viru
			tagstatus.append(result["name"])
			server = ''.join(tagstatus)
			dat = system.tag.read('[MQTT Engine]Edge Nodes/Robertsbridge/Energy/Electric/Compressors/'+server+'/Total_Consumption/Total_Consumption_kW').value
			test.append(dat)
			tagstatus = []
data = test
listIn = viru
listOut = [str(i) for i in listIn]
header = (["Label",listOut])
pyd = ([data])
out = system.dataset.toDataSet(header,pyd)
print out

#print data

```

---

<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:** [February 19, 2021, 5:05pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/10 "2021-02-19T17:05:55Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/d/5d69ac9ae1554291d6533d77e88f3ba78c742b18.png)  
i have attached picture of code also

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 19, 2021, 5:06pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/11 "2021-02-19T17:06:24Z")

</div>

![code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e8f717e3b23194ced28f88b991e2d3113dc308d.png)

Please edit your post pasting the code using this button

---

<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:** [February 19, 2021, 5:23pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/14 "2021-02-19T17:23:30Z")

</div>

A couple of questions:

- What is ‘Label’?
- Are you wanting your end results in a wide format like what you have started, or a tall one?

---

<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:** [February 19, 2021, 5:28pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/15 "2021-02-19T17:28:03Z")

</div>

Label i not given means i am getting error like this  
header = [listOut]  
**\>\>\> \*\*  
 Traceback (most recent call last):  
\*\* File “”, line 36, in**   
**IndexError: Row 0 doesn’t have the same number of columns as header list.**

---

<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:** [February 19, 2021, 5:31pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/16 "2021-02-19T17:31:26Z")

</div>

end result i want to use the dataset to stacked bar **(Wide format)**

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 19, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/17 "2021-02-19T17:32:37Z")

</div>

You need to extend the header list, you are embedding a list within the 2nd element.

```auto
header=['label'] + listOut
```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 19, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/18 "2021-02-19T17:32:48Z")

</div>

Look at the documentation here - [https://docs.inductiveautomation.com/display/DOC79/system.dataset.toDataSet](https://docs.inductiveautomation.com/display/DOC79/system.dataset.toDataSet)

It looks like your headers variable is wrong. Your headers should be a single list like `['column1', 'column2', ..., 'columnN']`

However your headers variable is `headers = ("Label", listOut)` which would be a tuple containing a string and then a list. Your headers variable should look like `['column1', 'column2', ..., 'columnN']` as mentioned. Same with the dataset. Pretty sure you want a list of lists - that may work with a tuple but I’ve never done it with a tuple, I usually have `[[row1 data], [row2 data]], ...]`.

The last error you posted though just means you have a different number of column headers and data columns.

---

<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:** [February 19, 2021, 5:33pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/19 "2021-02-19T17:33:03Z")

</div>

OK, start with:

```auto
header = listOut

```

We can work on simplifying and optimizing in a bit.

---

<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:** [February 19, 2021, 5:43pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/21 "2021-02-19T17:43:28Z")

</div>

In a stacked chart, the first column is considered the category, or what groups the values on each row together. You would actually need three columns.

What you require for the label of the category should be the value in the first column.

---

<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:** [February 19, 2021, 5:50pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/23 "2021-02-19T17:50:25Z")

</div>

You were very close the first time around. To combine them into a single list.

```python
header = ["Label"] + listOut
pyd = [['Label Text'] + data]

```

---

<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:** [February 19, 2021, 5:52pm UTC](https://forum.inductiveautomation.com/t/issue-in-split-list/43628/24 "2021-02-19T17:52:44Z")

</div>

Thank you much for your support. I have got the ouput

[Next page](https://forum.inductiveautomation.com/t/issue-in-split-list/43628.md?page=2)
