Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: svimesHi i have a column of data which is of the form string1 [string2].
String 1 and String 2 vary. In addition a few of the rows do not have [string2] they just have string1 and no square brackets.
I wanted to get string 1 and string 2 in separate columns, labelled PRODUCT _GROUP and PRODUCT respectively so I did:
split_field = string1.split("[")
PRODUCT_GROUP = string1.getItem(0).trim()
which is fine to get string 1.
However if i do
PRODUCT_GROUP = string1.getItem(1)
I get an index out of bounds error which I suspect is due to some rows not have an item(2) as it has no "[" character to split on. What's the way round this and am I doing this in the most efficient way? Thanks