# System tag read issue

**URL:** <https://forum.inductiveautomation.com/t/system-tag-read-issue/83452>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [December 21, 2023, 11:30pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-issue/83452 "2023-12-21T23:30:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Houston](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas_houston/32/68700_2.png) [@Nicholas\_Houston](https://forum.inductiveautomation.com/u/Nicholas_Houston)\
**Post date:** [December 21, 2023, 11:30pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-issue/83452/1 "2023-12-21T23:30:21Z")

</div>

When using system.tag.read and trying to get the value and evaluating it, I can't seem to get this to evaluate the way i'd expect. How do you detect if there is a Null value?

This is the result of the tag read.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9cae69a541c3c00f6e1760c976c4a4c710f2392.png)

If the first value is the only one with a value currently in it, why are they all reading as 'Full' with this line of code?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b7a07c6d46e5fe3ebe541aea001352406af8fd95.png)

---

<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:** [December 21, 2023, 11:37pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-issue/83452/2 "2023-12-21T23:37:45Z")

</div>

`u''` is the `repr` string-formatted output of an _empty string_, which is _falsey_ in Python, but distinctly different from the `None` singleton - so you can either:

1. Change your loop condition to check against 'truth' of a value, so empty strings, empty collections, None, `0`, and boolean `False` will all fail the condition:

```python
	read = system.tag.read("path").value
	if read:
		# it was truthy
	else:
		# it was falsey

```

1. Check for the empty string explicitly in your loop condition:

```python
	read = system.tag.read("path").value
	if read == "":
		# it was truthy
	else:
		# it was falsey

```

---

<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:** [December 21, 2023, 11:40pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-issue/83452/3 "2023-12-21T23:40:21Z")

</div>

As an aside, `system.tag.browse` is already a "heavy" operation. Pairing it with a bunch of individual `system.tag.read` calls is going to _kill_ your gateway if you're not careful.

In _every case_, prefer to aggregate tag reading and writing operations into the largest batches possible in your unit of scripting. In this case, something like this will run literally orders of magnitude faster:

```python
tagset = system.tag.browseTags(parentPath = "AGTC_FPA3_13/Door")
pileNumberPaths = ["%s/PileNumber" % tag.path for tag in tagset]
qualifiedValues = system.tag.readBlocking(pileNumberPaths)

for qv in qualifiedValues:
	read = qv.value
	if read:
		# it was truthy
	else:
		# it was falsey

```

---

<div class="post-metadata">

**Author:** ![Nicholas\_Houston](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nicholas_houston/32/68700_2.png) [@Nicholas\_Houston](https://forum.inductiveautomation.com/u/Nicholas_Houston)\
**Post date:** [December 22, 2023, 12:12am UTC](https://forum.inductiveautomation.com/t/system-tag-read-issue/83452/4 "2023-12-22T00:12:34Z")

</div>

@paul-griffith `Preformatted text`  
The end goal of this script is to sync pile and serial data to a database. Each rollerbed has an array of serials 1-50, I want to be able to look to see how many serials exist and then make an entry into the database for each individual serial. Is this something that can be done using a transaction group rather than looping in a script to get the information?  
I'm using a stored procedure and this is the code for that in Microsoft SQL

```auto
[dbo].[UpdatePileLocation](

@serial varchar(50), @Sequence int, @pile int, @location varchar(20))

```

1-50 entries per rollerbed, the sequence will auto increment until there is no more serial data, pile will remain the same, and location will remain the same.
