Is it possible to get the value of the variable from tJavaRow?

One Star

Is it possible to get the value of the variable from tJavaRow?

Hi there,
I have a job that is as follows:

It takes the value from specific cells from all the sheets in the workbook from the tFileExcelInput. It takes values from multiple cells and assigns them to a context variable. Each sheet is a row is the way to think of it.
I'm just stuck on how to output all the rows i.e. context variable values returned to either a tLogRow or OutputDelimited file?
Thanks,
Facoda

 
Community Manager

Re: Is it possible to get the value of the variable from tJavaRow?

Hi 
After you read the file and assign values to the context variables, you can use tFixedFlowInput to generate an input flow and output them to a file. For example:
tFileInputExcel-main--tJavaRow
   |
onsubjobok
   |
tFixedFlowInput--main-tFileOutputDelimited
on tFixedFlowInput, define the columns which data you want to output and set the value of each column with corresponding context variable. 
BR
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Is it possible to get the value of the variable from tJavaRow?

Hi Shong,
I've already tried this job design but it only seems to return the values on the first sheet. It does not return the values from all the sheets.
Thanks
Community Manager

Re: Is it possible to get the value of the variable from tJavaRow?

If you read all sheets, it should returns data of the last sheet with this job design. If you expect to output data for each sheet, you need to iterate each sheet, refer to this custom component shared by jlolling, or write down all the sheet name in a file and iterate each sheet name one by one. For example:
tFileInputDelimited--main(row1)--tFlowToIterate--Iterate-tFileInputExcel-main--tJavaRow-oncomponentok-tFixedFlowInput--main-tFileOutputDelimited
on tFileInputExcel, uncheck 'all sheet' box, and type in the sheet name in the Sheet list as below:
(String)globalMap.get("row1.sheetName")

//sheetName is the column name on tFileInputDelimited

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Is it possible to get the value of the variable from tJavaRow?

Hi Shong,
I'm not sure I totally understand this flow that you have. 
1.(String)globalMap.get("row1.sheetName") is a global variable but the tFileInputDelimited does not have such a variable output that it can pass onto another component? I'm not sure how you can get the sheet name from the tFileInputDelimited component. The tFileExcelSheetList is the only component that I know that can give me the sheet list as a variable such as- (String)globalMap.get("tFileExcelSheetList_1_SHEET_NAME"))
2.Defining (String)globalMap.get("row1.sheetName") in the column of tFileInputDelimited I'm not sure where the value for sheetName is coming from.
Thanks
Community Manager

Re: Is it possible to get the value of the variable from tJavaRow?

Hi 
If the sheet names are known and fixed, you can write them in a file and use tFileInputDelimited to read them. For example, a file contains the sheet names like:
sheet1
sheet2
...

Then, use a tFlowToIterate to iterate each sheet name, or use a tForEach to replace tFileInputDelimited-main->tFlowToIterate.
----------------------------------------------------------
Talend | Data Agility for Modern Business