Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert rows into columns ?

Hi,
I have an input XML file.
I would like to obtain the following result :
id | picture1 | picture2 | picture3
1 | 7355448.jpg | 7893544.jpg | 2364758.jpg
2 | 1234567.jpg | 7864125.jpg | 1478523.jpg
3 | 7391845.jpg | 7319846.jpg | 7829657.jpg
...
For one id, i can have one or several pictures.
In the output Excel, I would like to obtain only the first three pictures.
When I realize the mapping, I get the following result :
id | picture1
1| 7355448.jpg
1| 7893544.jpg
1| 2364758.jpg
1| 7365599.jpg
1| 7733548.jpg
2| 1234567.jpg
2| 7864125.jpg
2| 1478523.jpg
2| 1122778.jpg
2| 9977443.jpg
...
Can I do that with TOS ? How to solve the problem ?
Regards.
Labels (3)
26 Replies
Anonymous
Not applicable
Author

In fact, you are right on your before last reply. But me I have a tMap. And I catch the error in the tMap. I want to get the following result as you can get here :
| tLogRow_1 |
|=-+------------+------------+-----------=|
|Id|Picture_1 |Picture_2 |Picture_3 |
|=-+------------+------------+-----------=|
|1 | 7355448.jpg| 7893544.jpg| 2364758.jpg|
|2 | 1234567.jpg| 7864125.jpg| 1478523.jpg|
Can you try with a tMap ? To see if you catch the error (or not ?)
Regards
Anonymous
Not applicable
Author

Hi SPTIMAN,
I have created empty record on second row and then process with provided tMap solution it was fine except empty value for picture2 column.
Anonymous
Not applicable
Author

Hi,
In fact, I must obtain the following result :
| tLogRow_1 |
|=-+------------+------------+-----------
|Id|Picture_1 |Picture_2 |Picture_3 |
|=-+------------+------------+-----------
|1 | 7355448.jpg| 7893544.jpg| 2364758.jpg|
|2 | 1234567.jpg| 7864125.jpg| 1478523.jpg|
|3 | ZE554EF.jpg| | |
|4 | 5478752.jpg| 3244563.jpg| |
|5 | 1234567.jpg| 7864125.jpg| 1478523.jpg|
|6 | 6745656.jpg| 3742264.jpg| 6745456.jpg|
The error is caught at the line 3 (here) in the column 2 : empty value : that's why I catch the exception...
row1.picture.split(";") is not correct here ? That's why I have the error here
For an id, I can have only one picture or two pictures (or nothing !).
Anonymous
Not applicable
Author

Anyone ?
Anonymous
Not applicable
Author

for first column: row6.picture1!=null? row6.picture1.split(";").length >0?row6.picture1.split(";"):null
:null
for second column: row6.picture1!=null? row6.picture1.split(";").length >=1?row6.picture1.split(";"):null
:null
for third column: row6.picture1!=null? row6.picture1.split(";").length >=2?row6.picture1.split(";"):null
:null

have you used same way as i stated in my previous reply? because it will check whether array has values more than we require then it will execute or assign to the column. it is working at my place.
Anonymous
Not applicable
Author

Hi, there,

I want to transpose my file. Format is below:

Input File: It is a tabulation delimited file

IDOC Number 00000012321

Name John Lewis

Net Weight 0.000

Weight Unit KGM

Output File:

IDOC Number;Name;Net Weight;Weight Unit

00000012321;John Lewis;0.000;KGM;

How to do it in Talend?

akumar2301
Specialist II
Specialist II

fhello @stuti_206

 

if number of columns are fix and in correct order in input file ,

1) create an id for each set of data. below records belong to single set , so add 1 as id for all 

2) set schema of 3 columns id,question,answer and  change delimter to ; ( this is just to sync with example mention in below link )

3) use tPivotToColumnDelimited

https://help.talend.com/reader/NNO~fmVQU4rlkF9Depfdxw/GW_EzpRJPsxxxIbzHtGxjQ

4) filter id column if not required