# Dataset to type class java.lang.Integer

**URL:** <https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [October 25, 2023, 9:04am UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952 "2023-10-25T09:04:14Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [October 25, 2023, 9:04am UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/1 "2023-10-25T09:04:14Z")

</div>

I have been using the script from the exchange to extract all the tag values from my udt tag see pic(3), and would like to have my float values included as well see Pic (1) if "[" "]" not added to the append statement for the var newData.

I not sure whether this is only related to the ",." issue

We use "," as decimal separator

If I put square bracket around [newData] when appending works fine however my result requires extra handling which I would like to avoid.  
Any good ideas, try to fix it in the script or move the handling of the different data types to the view when presenting them ?

See picture (2) below from Perspective view.

def getAllTheTagz(udtPath):

```
tagPaths = [tag.fullPath for tag in system.tag.browseTags(parentPath = udtPath, recursive = True ) if not tag.isFolder() and not tag.isUDT()]
print tagPaths
_results = system.tag.readAll(tagPaths)
var = 1.1
theTagz = {}
theTagy =[]
headers =["Tag Name","Value"]#,"Last Ok"]
today = system.date.now()

for i in range(len(tagPaths)):
	newDataType = type( _results[i].value)
	
	if newDataType == type(1) or newDataType == type(var) or newDataType == type("string") or newDataType == type(False) or newDataType == type(today):
		newData = _results[i].value
		#print i,str(tagPaths[i][len(udtPath):]),newData, type(newData)
		theTagy.append([str(tagPaths[i][len(udtPath):]),newData])
		#theTagy.append([str(tagPaths[i][len(udtPath):]), _results[i].value])
		
myRecipieValues = system.dataset.toDataSet(headers, theTagy)
return myRecipieValues #theTagy

```

Pic (1)

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

Pic(2)

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

Pic(3) Rawdata from tag  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/23358daa43b76ab626c54e2186318b8f64d25556.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 25, 2023, 11:06am UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/2 "2023-10-25T11:06:15Z")

</div>

Pretty sure dataset columns can only have one type.  
By putting the `[]` around it you made the type string.

---

<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:** [October 25, 2023, 11:25am UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/3 "2023-10-25T11:25:46Z")

</div>

I can't test it right now but I believe your `getAllTheTags` function could be a simplified a bit:

```python
def getAllTheTags(udtPath):
	tagPaths = [tag.fullPath for tag in system.tag.browse(udtPath, {'tagType': "AtomicTag", 'recursive': True})]
	_results = system.tag.readBlocking(tagPaths)
	headers = ["Tag Name","Value"]#,"Last Ok"]
		
	data = [
		[
			path.lastPathComponent,
			tag.value
		] for tag, path in zip(_results, tagPaths)
			if isinstance(tag.value, (int, float, str, bool, java.lang.date))
	]
	return system.dataset.toDataSet(headers, data)

```

The java.lang.date might not be the right type, but you get the idea.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 25, 2023, 11:41am UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/4 "2023-10-25T11:41:04Z")

</div>

You cant make a dataset with different types so this whole function doesnt work tbh.  
You should not return it as dataset, just as ("json") object array.  
The table can display that too

---

<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:** [October 25, 2023, 12:07pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/5 "2023-10-25T12:07:01Z")

</div>

> [@pascal.fragnoud](#):
>
> The java.lang.date might not be the right type

`java.util.Date`

---

<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:** [October 25, 2023, 12:10pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/6 "2023-10-25T12:10:09Z")

</div>

> [@victordcq](#):
>
> You cant make a dataset with different types

Actually, you can specify `java.lang.Object` as a column type, then you can put anything in the column. But a json list of mappings is better for a Perspective table.

---

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [October 25, 2023, 1:08pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/7 "2023-10-25T13:08:30Z")

</div>

thanks I will create a JSON object array instead off.

---

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [October 25, 2023, 2:02pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/8 "2023-10-25T14:02:53Z")

</div>

That did work very well,  
Any idea to create a style for formatting based on the result from isinstance unless it straight forward to build some logic after the value field  
Would like to swap "," and "." and maybe do some formatting on the Boolean

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 25, 2023, 2:09pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/9 "2023-10-25T14:09:47Z")

</div>

The options for that are in.  
props.column  
[https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table)  
you'll have to add the two columns there.

---

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [October 25, 2023, 2:58pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/10 "2023-10-25T14:58:01Z")

</div>

Yep, Columns already added.  
But looking for how to do the ".," swap so it's aligned with my local format.  
Which is "," as decimal separator.

---

<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:** [October 25, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/11 "2023-10-25T15:02:45Z")

</div>

Fill in the `columns` array and customize the rendering of each column there.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 25, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/dataset-to-type-class-java-lang-integer/80952/12 "2023-10-25T15:02:55Z")

</div>

You might be forced to bind the format string of the column against the session locale and then use a Map transform within the binding. Also, make sure the `field` property for the column config is pointing to the desired column in your data.
