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: 
sk0
Contributor
Contributor

Split the input string based on \n (newline character) and then assign each string to different n number of rows

Hi,

requirement: Split the input string of one column based on \n (new line character) and then capture first 5strings that are splitting earlier and then assign those 5strings to 5 different rows

How can do this 

Actually I am reading a column which has n-number of strings with the new line character as a separator. 

I need to read the whole string and then split the string based on newline character and then assign the 1st string to one output component and 2nd string to another output component and 3rd string to third output component.

Can do this in tmap? If yes can someone please share me the example. Or if there’s another approach please let me know with an example.

input column1:

data

mailing

details

output:

row1: Data

row2: mailing

row3: details

thanks in advance!

Labels (2)
7 Replies
Anonymous
Not applicable

Hi

Try the tNormalize component, this component can be used to split the column value to multiple rows.

 

Regards

Shong

sk0
Contributor
Contributor
Author

Hi @Shicong Hong​ I tried using tNormalize component and it didnt worked for me. In ITEM SEPARATOR i mentioned as "\n"

sk0
Contributor
Contributor
Author

Can someone please help with the above issue

 

Anonymous
Not applicable

@S K​, Which OS? I made a testing on Windows, read the file content as a string , the file has 3 row of data in it , I set the separator as "\r\n" on tNormalize component, see below.

0695b00000RiJgHAAV.png 

 

Regards

Shong

sk0
Contributor
Contributor
Author

I used tfileinputdelimited and it didn’t worked but when I used tfilerawinput component it worked fine. Is there’s a way that I can implement the same logic in tmap? Please let me know
Anonymous
Not applicable

where's the data are stored in real case? tfileInputRaw read the whole file content as only one row, tfileInputDelimited read the file line by line and the output data will not contain \n new line character.

tMap is not the right component used to split one row to multiple rows.

sk0
Contributor
Contributor
Author

Thanks Shong for your time and help. Appreciated