# Converting a string to a string array using split()

**URL:** <https://forum.inductiveautomation.com/t/converting-a-string-to-a-string-array-using-split/24695>\
**Category:** General Discussion\
**Tags:** scripting\
**Created:** [May 6, 2019, 3:49pm UTC](https://forum.inductiveautomation.com/t/converting-a-string-to-a-string-array-using-split/24695 "2019-05-06T15:49:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timothy.tickner](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@timothy.tickner](https://forum.inductiveautomation.com/u/timothy.tickner)\
**Post date:** [May 6, 2019, 3:49pm UTC](https://forum.inductiveautomation.com/t/converting-a-string-to-a-string-array-using-split/24695/1 "2019-05-06T15:49:39Z")

</div>

Hi Ignition Forum,

I have a string coming in over TCP from an RFID reader that I’m looking to parse into an array. I’m testing some code in the Script Console and running into a problem I wouldn’t expect. Here is my code:

```auto
from string import split
# Read in the TCP tag.
reader1 = system.tag.read("[default]JBS Truck Tracking/14150/Message")

print(reader1)

# Convert the string into a StringArray.
string_array = reader1.split(',')

# Write the array to Reader1Array
system.tag.write('[default]JBS Truck Tracking/Reader1Array', string_array)

```

The import works fine, no error. The `system.tag.read()` works fine, no error. The print works fine, no error. When I try to use the .split() function, I get:

```auto
Traceback (most recent call last):
  File "<buffer>", line 8, in <module>
AttributeError: 'com.inductiveautomation.ignition.common.sqltags.Ba' object has no attribute 'split'

```

I’ve tried various implementations of the split function because I’m not 100% sure which one to use, every time I receive the AttributeError though. Here are some other formats I’ve tried:

```auto
string_array = reader1.split(reader1, ',')
string_array = string.split(reader1, ',')
reader1.split(',')

```

All ideas are good ideas! Thank you in advace!

---

<div class="post-metadata">

**Author:** ![grietveld](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grietveld/32/6984_2.png) [@grietveld](https://forum.inductiveautomation.com/u/grietveld)\
**Post date:** [May 6, 2019, 3:52pm UTC](https://forum.inductiveautomation.com/t/converting-a-string-to-a-string-array-using-split/24695/2 "2019-05-06T15:52:10Z")

</div>

The read returns a qualifiedValue, so it has the value as well as a quality and timestamp.

Try reader1.value.split(’,’)

---

<div class="post-metadata">

**Author:** ![timothy.tickner](https://avatars.discourse-cdn.com/v4/letter/t/e480ec/32.png) [@timothy.tickner](https://forum.inductiveautomation.com/u/timothy.tickner)\
**Post date:** [May 6, 2019, 3:56pm UTC](https://forum.inductiveautomation.com/t/converting-a-string-to-a-string-array-using-split/24695/3 "2019-05-06T15:56:35Z")

</div>

Ahhhh that was it! I knew it must be something simple. Thanks so much!
