# read and search for a value in a file

**URL:** <https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296>\
**Category:** Raspberry Pi\
**Created:** [July 5, 2016, 12:01pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296 "2016-07-05T12:01:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Rogg](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/bcef8e/32.png) [@Fabian\_Rogg](https://forum.xojo.com/u/Fabian_Rogg)\
**Post date:** [July 5, 2016, 12:01pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296/1 "2016-07-05T12:01:20Z")

</div>

Hi all,

I just work with my Raspberry Pi with a log-file which is updated each minute. Could someone help me with the code to read the content of the file and search for the right value in it? Furthermore, I should save the data which are read in a database.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Albin\_Kiland](https://forum.xojo.com/user_avatar/forum.xojo.com/albin_kiland/32/1028_2.png) [@Albin\_Kiland](https://forum.xojo.com/u/Albin_Kiland)\
**Post date:** [July 5, 2016, 10:54pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296/2 "2016-07-05T22:54:06Z")

</div>

To read a file, use [FolderItem](http://documentation.xojo.com/index.php/FolderItem)  
To save values into a db, use the [Database Class](http://documentation.xojo.com/index.php/Database_Class)  
What database do you want to use?  
Yo can use [InStr](http://documentation.xojo.com/index.php/InStr) to search for a string.

---

<div class="post-metadata">

**Author:** ![Fabian\_Rogg](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/bcef8e/32.png) [@Fabian\_Rogg](https://forum.xojo.com/u/Fabian_Rogg)\
**Post date:** [July 6, 2016, 1:47pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296/3 "2016-07-06T13:47:31Z")

</div>

Thx for your help Albin!

But how can I convert the FolderItem to a string? Because in the “temp1.txt” file is the word “temperature” stored and after it is a unknown value which I have to read and store in the table.  
I think I will use a MySQL database.  
Here is me current code:

```auto
  dim s as string
  dim f as FolderItem
  f= GetFolderItem("temp1.txt")
```

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [July 6, 2016, 1:48pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296/4 "2016-07-06T13:48:48Z")

</div>

Look at TextInputStream in the documentation.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:23pm UTC](https://forum.xojo.com/t/read-and-search-for-a-value-in-a-file/32296/5 "2020-10-29T18:23:06Z")

</div>


