# Read from text file

**URL:** <https://forum.inductiveautomation.com/t/read-from-text-file/4566>\
**Category:** General Discussion\
**Created:** [June 2, 2012, 4:43am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566 "2012-06-02T04:43:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mubin](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mubin](https://forum.inductiveautomation.com/u/mubin)\
**Post date:** [June 2, 2012, 4:43am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/1 "2012-06-02T04:43:11Z")

</div>

how to read values from text file and write to tags only once when values are changed?  
can any one give solution for this

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 4, 2012, 3:49am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/2 "2012-06-04T03:49:54Z")

</div>

You can do this in scripting either automatically every x amont of time or manually when someone presses a button. The script will be something like this:`fileStr = system.file.readFileAsString("C:\\Path\\To\\File.txt")
system.tag.writeToTag("Path/To/Tag", fileStr)`Of course that script is really simple, so in order to give you a better script what does your file look like? Is it a CSV? There are several ways to read in values and write them to tags.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 4, 2012, 3:52am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/3 "2012-06-04T03:52:16Z")

</div>

I just noticed that you posted this question twice: one here and one the Ignition section. Please don’t post this question to two different forums. In the future you only need to post the question once and we will answer it.

---

<div class="post-metadata">

**Author:** ![mubin](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mubin](https://forum.inductiveautomation.com/u/mubin)\
**Post date:** [June 9, 2012, 6:40am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/4 "2012-06-09T06:40:25Z")

</div>

this is not a csv file,it is a text file with comma delimited.  
atleast give me the reply for how to find out “a text file is changed or not”?  
what are the steps to find the text file is changed or not in ignition?  
please mention the steps.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 9, 2012, 7:39pm UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/5 "2012-06-09T19:39:57Z")

</div>

You could try this as well. The posted version is for 7.3, bit I’ll post the 7.4 and 7.5 versions really next week  
[viewtopic.php?f=88&t=7885](http://www.inductiveautomation.com/forum/viewtopic.php?f=88&t=7885)

---

<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:** [June 11, 2012, 9:15am UTC](https://forum.inductiveautomation.com/t/read-from-text-file/4566/6 "2012-06-11T09:15:30Z")

</div>

I’ll requote myself from the duplicate post…

[quote=“JordanCClark”]Since you’re looking for only changed values, you would need to grab the previous values. You can do this by either:

1: reading all your tags and comparing the values.  
2: renaming the file with the current values to hold the previous values. Then read two files (one with the current values and the one you renamed) and compare.  
[/quote]

How many tags are you processing? Depending on the number, there may not be a whole lot of overhead to worry about anyway.
