# Data Set Scripting

**URL:** <https://forum.inductiveautomation.com/t/data-set-scripting/90553>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [May 17, 2024, 9:44am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553 "2024-05-17T09:44:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Jackson](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steven\_Jackson](https://forum.inductiveautomation.com/u/Steven_Jackson)\
**Post date:** [May 17, 2024, 9:44am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/1 "2024-05-17T09:44:13Z")

</div>

Hi,  
I have a Scheduled Gateway script to read data from a .csv file and push it out to a data set tag.  
I have  
file\_path = "C:\Users\SJ\Downloads\PLCTags.csv"  
# Read in the file as a string.  
string = system.file.readFileAsString(file\_path)  
# Convert the string to a dataset and store in a variable.  
dataset = system.dataset.fromCSV(string)

So far so good.... however, I can't seem to then write out to a dataset tag.  
I've tried the conversion commands  
system.dataset.toPyDataSet and system.dataset.toDataSet without success.  
I'm probably missing something simple ??!

Cheers

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 17, 2024, 9:52am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/2 "2024-05-17T09:52:30Z")

</div>

Hi, Stephen. Please have a read of [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831) and then fix your original post. We can't tell if you've indented properly.

---

<div class="post-metadata">

**Author:** ![Steven\_Jackson](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steven\_Jackson](https://forum.inductiveautomation.com/u/Steven_Jackson)\
**Post date:** [May 17, 2024, 10:20am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/3 "2024-05-17T10:20:34Z")

</div>

I've check, it's indented properly.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 17, 2024, 10:22am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/4 "2024-05-17T10:22:39Z")

</div>

Can you post your entire code block please?

And any errors?

---

<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:** [May 17, 2024, 10:30am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/5 "2024-05-17T10:30:12Z")

</div>

Is the tag's readOnly property set to True? If so, set it to False.

Also, make sure you are using the following syntax to write the dataset to the tag:

```python
system.tag.writeBlocking(['path/to/tag'], [dataset])

```

I don't see anything like this in your code snippet.

---

<div class="post-metadata">

**Author:** ![Steven\_Jackson](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steven\_Jackson](https://forum.inductiveautomation.com/u/Steven_Jackson)\
**Post date:** [May 18, 2024, 2:53am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/6 "2024-05-18T02:53:49Z")

</div>

Hi.  
This is what I had originally  
`system.tag.write("tagpath", "dataset")`

Which didn't work

Then I went to your suggestion

`system.tag.writeBlocking([tagpath], [dataset])`

Which works !!

Cheers

---

<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:** [May 18, 2024, 3:04am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/7 "2024-05-18T03:04:10Z")

</div>

> [@Steven\_Jackson](#):
>
> write("tagpath", "dataset")

Your dataset variable is in quotes making it a string. That's probably why the tag write wasn't working, but nevertheless, the write blocking method is the most up to date way to handle tag writes, so it's good that you changed the syntax.

---

<div class="post-metadata">

**Author:** ![Steven\_Jackson](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steven\_Jackson](https://forum.inductiveautomation.com/u/Steven_Jackson)\
**Post date:** [May 21, 2024, 1:34am UTC](https://forum.inductiveautomation.com/t/data-set-scripting/90553/8 "2024-05-21T01:34:28Z")

</div>

Hi,  
That's good to know.

Thanks again.
