[resolved] TMAP

Four Stars khg
Four Stars

[resolved] TMAP

Hi,
i must read a text file with different line and make xml file in the end.
TfileInputPositional ---- > TMAP -----> TadvancedOutputXML
the structure in my file text:
01023597411
04563589685 2222
05469833333 2568
05469833333 3333
07565665656
in my tmap i created column
for the lines with code 01/07/04 i read all, but for my line with code 05 i must read only 4 last characters,
the problem is when i have an empty data for my line 05 when i generate my xml file.
How can i say in tmap for the line start with 05 you must read only last characters
Thanks.

Accepted Solutions
One Star

Re: [resolved] TMAP

Alternatively, after converting your file to delimited using your positional map, you can use the tFileInputMSDelimited component which is designed to parse multi-schema files such as yours...
See http://www.talendforge.org/tutorials/tutorial.php?idTuto=56

All Replies
One Star

Re: [resolved] TMAP

Is the source file a fixed column width file or delimited file or ???
Based on this only we can say how to use tMap or Regex etc...
Please tell us the pattern in which the source file exist (like number of columns and how each columns are delimited etc).
Four Stars khg
Four Stars

Re: [resolved] TMAP

the soource file is TfileInputPositional with fixed column the model is ""2,5,4,5,3,1,1,11,2,6,2,6,31,2,7,1,1,14,16,3,70,2"
One Star

Re: [resolved] TMAP

got it... So you parse the file and get all the columns right...
Use the tMap component and use the equals operator to check the first 2 characters and based on that, use the columns which you want
For example, if your column name is Col1, then
row1.Col1.equals("05")?<consider the last column>:<consider other column>
The column to be placed after ? is the true condition (means column related to 05)
The column to be placed after : is the false condition (means column to consider for 04/01/07)
So based on the condition, use which column to be placed where
One Star

Re: [resolved] TMAP

Hi khg,
I can give you an idea :
My quick code : row1.line.startsWith("05")?row1.line.split(" "):row1.line.split(" ");
One Star

Re: [resolved] TMAP

Alternatively, after converting your file to delimited using your positional map, you can use the tFileInputMSDelimited component which is designed to parse multi-schema files such as yours...
See http://www.talendforge.org/tutorials/tutorial.php?idTuto=56
One Star

Re: [resolved] TMAP

Hi khg,
Please post your requirement properly..
Your first post is contradicting the second...
You said you need to retrieve last four characters if it of type 05, but the model what you have given does have only 2 characters at the last and last but has 70 ???
Are you missing something?
If you use a FileInputPositional component, then you could have got all the data in their respective columns right. If so use the respective column outputs to determine the way you want the output to be by specifying the condition mentioned above...
Four Stars khg
Four Stars

Re: [resolved] TMAP

Thanks for your replies, i found the solution.