Reputation: 23
I would like to know how I can count the number of columns of an excel sheet using Talend
Upvotes: 0
Views: 812
Reputation: 1592
tFileInputExcel (just read 1 row i.e. column headers record) ----> tFileOutputDelimited
tFileInputDelimited (read the file created above) --> tNormalize --> tFilterRow_1 (filter null & blank rows) --> tJava_1
In tJava_1 component, you can get the number of rows by using (String)globalMap.get("tFilterRow_1_NB_LINE_OK").
This number of rows actually represent your number of columns in excel.
Upvotes: 0
Reputation: 765
If you want to count no. of columns in the Excel file then please follow the below instructions.
Use tfileinputExcel component.
Add some basic instruction in the component with limit 1 but important is "Put one name in Schema 'excel_header' (You can use any name) and change its type to 'Dynamic' ". It will fetch the full row from the excel file.
Now Use second component 'tjavaRow'. Link your excel component through the 'main' row to tjavarow component.
Syn your schema in tjavarow component and put below mentioned code.
System.out.println("Counter ::: "+input_row.excel_heade.getColumnCount());
Note: You can store this counter value in any context variable and can use it.
Thank you
Upvotes: 1