# Array/Dataset to a Dataset tag

**URL:** <https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128>\
**Category:** Ignition\
**Tags:** ignition79, database, scripting\
**Created:** [April 6, 2022, 6:45pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128 "2022-04-06T18:45:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [April 6, 2022, 6:45pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128/1 "2022-04-06T18:45:11Z")

</div>

I am trying to to take an array that i would use for a dataset and use it to push into a dataset tag

Here is the code I am currently running and

```auto
data = []
if len(myparams) > 0:
	headers = myparams[0].keys()
	for row in myparams:
		rowdata = []
		for key,value in row.items():
			rowdata.append(value)
		data.append(rowdata)
	
	ds = system.dataset.toDataSet(headers,data)
	event.source.parent.getComponent('Power Table').data = ds

```

I want to do something like

```auto
data = []
if len(myparams) > 0:
	headers = myparams[0].keys()
	for row in myparams:
		rowdata = []
		for key,value in row.items():
			rowdata.append(value)
		data.append(rowdata)
	
	ds = system.dataset.toDataSet(headers,data)
        system.tag.write("tagdata", system.dataset.setValue(ds, row, col, newVal))

```

Not sure what I am missing.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 6, 2022, 6:55pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128/2 "2022-04-06T18:55:46Z")

</div>

I am not seeing where you are writing anything to a database. Looks like you are converting a list into a dataset and attempting to write that to a tag.

---

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [April 6, 2022, 7:00pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128/3 "2022-04-06T19:00:53Z")

</div>

@josborn Correct, I changed my scope after I started. I had been planning on writing to a SQL table but I can get by just writing to a dataset memory tag. I have edited to match my scope change.

I have a dataset of about 20 columns and 140 rows that I want to move into the dataset tag once a day.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [April 6, 2022, 7:13pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128/4 "2022-04-06T19:13:54Z")

</div>

What’s the last line supposed to be doing, its outside of your loop, and the indentation looks wrong. Writing a dataset to a tag is pretty straight forward, why not just `system.tag.write("tagdata", ds)`

---

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [April 6, 2022, 8:59pm UTC](https://forum.inductiveautomation.com/t/array-dataset-to-a-dataset-tag/58128/5 "2022-04-06T20:59:14Z")

</div>

Welp, I thought I had tried just that but I must have missed something. It worked just as it should.  
I thought it should be that straight forward.

The indent wasn’t in my actual code, it was in the right spot.
