Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mani1304
Creator
Creator

Split Address field

Hi All,

In my requirement, I have 2 fields, address_1, address_2 and each has length 35, so if length increases 35, address will spill to address_2, but here we need full word, means if address_1 is having incomplete word then it should also move to address_2 field, e.g. if address_1's last word is not able to take all the words from Washington, then it should move the whole last word to address_2, hope this explains my requirement, can someone please tell about it.

Labels (3)
7 Replies
Anonymous
Not applicable

Hi

First of all, you need to check the length of address and filter the records that whose length exceeds 35, and then split the field to multiple parts. We usually split the text fields using tExtractDelimitedField components or hard code based on the specific requirements, can you show us some example data and what are expected output? So that we can give you more details.

 

Regards

Shong

mani1304
Creator
Creator
Author

Thanks Shong, I did it in tmap through creating variables, In first variable, splitted the record having more than 35 length, then took the record till lastIndexOf(" ") and combined the rest with add2 in third variable, Is there any other way for that?

tnewbie
Creator II
Creator II

Mani, using regular expression and checking for a non alphanumeric character in 35th position might be a better bet. If the 36th position has a alphanumeric then traverse back till you hit a non-alphanumeric and push the rest to the second line.

mani1304
Creator
Creator
Author

Thanks tnewbie, I was also thinking for using RegEx but may be I was doing some mistake and wasn't able to achieve it so took this method; if you don't mind can you provide some line of code for that.

Anonymous
Not applicable

Would you mind sharing some example data and what are expected output?

mani1304
Creator
Creator
Author

Hi Shong,

You can take below as an example

addr1- Flat Number 1901A, Bhagirathi Apartments(40 letters)

addr2- Sector 62, Noida, India(23 letters)

 

after mapping

 

addr1- Flat Number 1901A, Bhagirathi

addr2- Apartments Sector 62, Noida, India(Apartments moved because last word Apartments was not completing in 35 letters)

Anonymous
Not applicable

@Manish Mishra​ , Yes, if the length exceeds 35 and you always want the rest of characters starting with the last blank space are moved to the second address, the way you are doing is the best and quick.

 

Regards

Shong