tmap component with default output values

One Star

tmap component with default output values

Hi,
I am using tmap to get my consolidated output excel, I need to get default values in my output excel sheet columns. How can I set the default values for each fields of my tmap output?
Is there any ways to split and paste the output values in three different rows of an output excel?
Please let me know your pointers and updates.
Thanks and Regards,
Mani.
One Star

Re: tmap component with default output values

On the right side of tMap you can put fix values into output "Expression" column.
If you want to create more than one output row from one input row, define several (n times)output tables in tMap and connect these with ExcelOutput, that is copied n times to.
Split from input rows you can perform through Var area.
If you want to splint input string into m pieces, create m variables with the same input, but different transformation and different output tables.
I hope it will works
One Star

Re: tmap component with default output values

Hi Mani,
first to set a default value in tMap use the following code (java):
inputRow.field1 == null? "Your default" : inputRow.field1

Your second question is not clear for me: You need "different rows of an output Excel" (?)
Do you mean two Excel files? One Excel file with three rows for each input row (with the same value) or one Excel file with three rows for each input row but different values (and possibly different structure)?
Best would be to give us an example.
Bye
Volker
One Star

Re: tmap component with default output values

Thanks for the updates,
For one input row, I need 3 output rows to be generated under one coloumn name.
One is for summmary, other one for tax and one more for analysis.
"One Excel file with three rows for each input row"
Regards,
Mani.
One Star

Re: tmap component with default output values

Find below the details,
Is there any ways to get 3 rows output under one column for one row of input value.
Ex: row1.default1 value should reflected in 3 rows of tmap output table under one column name. (The value then used to calculate summary, tax and analysis as per calculations)
Components used in Job design:
tFileInputExcel - tmap component - tFileoutputExcel
Is the Java code generated in Talend is editable?
Please let me know your pointers and updates,
Mani.
One Star

Re: tmap component with default output values

Hi Mani,
if you need more than one output for one line I would say there are two solutions:
Create your data in different files but each with one key to merge them together in a second step (tUnite for example). So you could do different processes to calculate your values and merge them together in a later step.
Or use tNormalize if all values are the same in one column will have the following content "10,5,2" you could normalize the data with "," as separator.
One example with some more data (input and output) would be nice if you have more detailed questions.
Bye
Volker
One Star

Re: tmap component with default output values

Thanks for your updates and help - Please refer the below details,
Input.xls:
Column1 Column2 Column3
Row 1 value1 value2 value3 (one input value)
Row 2 value1 value2 value3 (one input value)
Output.xls:
Column1 Column2 Column3
Row 1 value1 value2 value3 (default value for summary)
Row 1 value1 value2 value3 (tax calculated based on formulas)
Row 1 value1 value2 value3 (Analysis value)
Row 2 value1 value2 value3 (default value for summary)
Row 2 value1 value2 value3 (tax calculated based on formulas)
Row 2 value1 value2 value3 (Analysis value)
I read from input.xls using the tFileInputExcel
Map the details using tmap component
Retrieve the o/p xls using tFileoutputExcel
As explained above I need 3 rows of o/p for my one single row i/p
under the same column.
Thanks and Regards,
Mani.
One Star

Re: tmap component with default output values

Hi Mani,
in this case use tNormalize. Add a new column to your input stream (for example in tMap or tJavaRow) and set a fix value for it: "default,tax,analysis". After this use tNormalize for this new column and use "," as separator. Now you will have the following data:
           Column1   Column2   Column3  NewColumn
Row 1 value1 value2 value3 default
Row 1 value1 value2 value3 tax
Row 1 value1 value2 value3 analysis
Row 2 value1 value2 value3 default
Row 2 value1 value2 value3 tax
Row 2 value1 value2 value3 analysis

Now you could process your data and apply calculations based on the newColumn. One simple example for tJavaFlex:
// code in start
Integer my defaultValue;
// code for each row
if (input_row.newColumn.compareTo("default") == 0) {
defaultValue= input_row.Column3;
output_row.Column3= input_row.Column3
} else if (input_row.newColumn.compareTo("tax") == 0) {
output_row= defaultValue * 0,19 // calculate 19% from default value in column 3
}

And so on...
Bye
Volker
One Star

Re: tmap component with default output values

Thanks for the response Volker, its working now.(tmap and tNormalize combination)
While reading an excel file I want to eliminate first 3 rows of an excel and start the
process from 4th row onwards.
I am using tFileInputExcel component - is there any ways to customize the read process?
Please let me know your pointers and updates.
Thanks and Regards,
Manikandan.R
One Star

Re: tmap component with default output values

Hi,
isn't there a parameter for header lines? This will define how many rows are ignored.
If not you could add a Numeric.Sequence() to your data and set a filter on rowNumber > 3 for example.
Bye
Volker
One Star

Re: tmap component with default output values

Hi Volker,
Thanks for the reply,
Please refer the below details,
Column1 Column2 Column3 NewColumn Line
Row 1 value1 value2 value3 default 1
Row 1 value1 value2 value3 tax 1
Row 1 value1 value2 value3 analysis 1
Row 2 value1 value2 value3 default 2
Row 2 value1 value2 value3 tax 2
Row 2 value1 value2 value3 analysis 2
I need to generate the Line values based on the input row readed. (Ex: row 1 the Line value is 1)
How can I get the values based on input rows and the total count of input rows in my tmap.
Please let me know your pointers and updates.
Thanks and Regards,
Mani.
One Star

Re: tmap component with default output values

Hi,
if you use tNormalize and set your Numeric.Sequence in front of it, you will get the output as written.
I think the best will be to post an example input and an example output with more real data. Than I could try to write an example job.
Bye
Volker