# Ignition Dataset History Retrieval from Canary

**URL:** <https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [September 6, 2023, 2:07pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814 "2023-09-06T14:07:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![derrickdvdsn](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@derrickdvdsn](https://forum.inductiveautomation.com/u/derrickdvdsn)\
**Post date:** [September 6, 2023, 2:07pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814/1 "2023-09-06T14:07:20Z")

</div>

I am trying to historize datasets in Canary Historian and retrive their value which I am able to do but I can't seem to read the values in the historized dataset.I am also not able to convert it to a dataset as it is unicode.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d7a2b42db6a65ec39ed0763198c68bd559a50222.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/0080dd2b5c46b55eb2bad01e297ed1a6f9a0a25b.png)

---

<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:** [September 6, 2023, 2:31pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814/2 "2023-09-06T14:31:46Z")

</div>

ds1[0][1] is of type `unicode` per your print statement so that is why you can't directly convert that to a dataset.

To use `system.dataset.toDataSet()`[system.dataset.toDataSet - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.dataset.toDataSet?gclid=Cj0KCQjwxuCnBhDLARIsAB-cq1rdvtyYPRWIDVu34qsl9WytEB3Ll4ucEoWYkJIKqkgh_8FdPjgR7Y0aAja4EALw_wcB) you should either feed it the full PyDataSet directly like `system.dataset.toDataSet(ds1)` or you can manually make a dataset with a row of headers and list of lists, like `system.dataset.toDataSet(['header1', 'header1', [[1,2], [3, 4]])`

Worth pointing out `system.tag.queryTagHistory` returns a Dataset initially, your `ds` variable is already a basic dataset.

---

<div class="post-metadata">

**Author:** ![derrickdvdsn](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@derrickdvdsn](https://forum.inductiveautomation.com/u/derrickdvdsn)\
**Post date:** [September 6, 2023, 3:25pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814/3 "2023-09-06T15:25:06Z")

</div>

so how can I access the values in the dataset (ds1[0][1]) that is in unicode? or how to convert unicode to dataset?

---

<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:** [September 6, 2023, 3:33pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814/4 "2023-09-06T15:33:13Z")

</div>

You _already have_ a dataset. The value at row 0, column 1, is _the string representation of a dataset_, meaning that the data in the inner dataset has already been lost. It's not immediately clear to me whether this is a thing Canary is even capable of supporting through our `queryTagHistory` API; **every Ignition system** is going to expect a tag history result to be 'scalar' in nature, even if datasets are _technically_ capable of this nesting operation.

You will probably need a more specific Canary function/operation to retrieve the 'nested' datasets in a more purpose-built structure. I don't know whether Canary already contains such functionality or not.

---

<div class="post-metadata">

**Author:** ![Jonathon\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jonathon\_Taylor](https://forum.inductiveautomation.com/u/Jonathon_Taylor)\
**Post date:** [June 11, 2025, 10:00pm UTC](https://forum.inductiveautomation.com/t/ignition-dataset-history-retrieval-from-canary/78814/5 "2025-06-11T22:00:09Z")

</div>

Here is a script I wrote that is working with Ignition 8.1.47 and Canary 23.2.0.23331 to return API data using parameters... it gives an idea for iterating through the json result which I think would be a good alternative to the OP.

```python
import json

# Define the URL for the GET request
url = https://<hostname>:55236/api/v2/getTagData

# Define the parameters
params = {
			"accessToken":"<>",
			"tags": "< tagPath >",
			"startTime": "Now-1000Hours",
			"endTime": "Now",
			"includeQuality": 'true',
			"maxSize": 15
}

# Create a query string from the parameters
query_string = "&".join(["{}={}".format(key, value) for key, value in params.items()])

# Complete URL with query parameters
complete_url = "{}?{}".format(url, query_string)

# Create an HTTP client with bypass_cert_validation = True
client = system.net.httpClient(bypass_cert_validation=True)

# Perform the GET request
response = client.get(complete_url)

# Check if the response is good
if response.good:
    print "GET Response Content:", response.text
    try:
        # Parse the response as JSON
        response_data = json.loads(response.text)
        print "Parsed GET Response Data:", response_data
        
        # Access specific fields if needed
        status_code = response_data.get("statusCode", "Unknown")
        errors = response_data.get("errors", [])
        data = response_data.get("data", {})
        
        # Print or process the data as necessary
        print "Status Code:", status_code
        print "Errors:", errors
        print "Data:", data
        
        # If you need to access specific tag data
        tag_data = data.get('<tagPath>', [])
        print "Tag Data:"
        for entry in tag_data:
            timestamp = entry.get('t')
            value = entry.get('v')
            quality = entry.get('q', 'Unknown') # Assuming 'q' is the field for quality, default to 'Unknown' if missing
            print "Timestamp: {}, Value: {}, Quality: {}".format(timestamp, value, quality)
        
    except Exception as e:
        print "Failed to parse JSON response:", str(e)
else:
    print "Failed GET request. Status code:", response.statusCode
    print "Response message:", response.message

```
