# AttributeError: 'NoneType' object has no attribute 'replace'

**URL:** <https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505>\
**Category:** Ignition\
**Created:** [April 14, 2016, 3:37pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505 "2016-04-14T15:37:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DWeber](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@DWeber](https://forum.inductiveautomation.com/u/DWeber)\
**Post date:** [April 14, 2016, 3:37pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505/1 "2016-04-14T15:37:33Z")

</div>

I receive this error when executing the following script. I highlighted the section that’s causing the issue. col4.replace("’", “’’”)

Traceback (most recent call last):

File “event:actionPerformed”, line 25, in

AttributeError: ‘NoneType’ object has no attribute ‘replace’

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [April 14, 2016, 3:44pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505/2 "2016-04-14T15:44:03Z")

</div>

Hello,

If you check the rows in the vwProductionCounts table in the LabelDesc column you should see one or more NULL values.

So when you query the database table and get the values for LabelDesc (row(3)) you get Python’s version of NULL which is None. And the None value does not have a “replace” method so you get the error you are getting.

You could make the default value for this column in the database an empty string so that you don’t get this error or handle the problem in another way.

Best,

---

<div class="post-metadata">

**Author:** ![DWeber](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@DWeber](https://forum.inductiveautomation.com/u/DWeber)\
**Post date:** [April 14, 2016, 3:52pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505/3 "2016-04-14T15:52:40Z")

</div>

I do not have control over the database I am connected to that’s why I am pulling these values and dumping them into our local database using this script. I checked that value and you are correct it is null. Is there a way around this with the script?

---

<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:** [April 14, 2016, 3:56pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505/4 "2016-04-14T15:56:42Z")

</div>

If you need to massage it you can try something like:

`if row[3] == None:
  col4 = ''
else:
  col4 = row[3]`

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [April 14, 2016, 4:09pm UTC](https://forum.inductiveautomation.com/t/attributeerror-nonetype-object-has-no-attribute-replace/11505/5 "2016-04-14T16:09:54Z")

</div>

You could also handle this in your query using COALESCE().

COALESCE(LabelDesc, ‘’)

will return an empty string if LabelDesc is NULL.
