Sarah Ghaya
Sarah Ghaya

Reputation: 23

Counting number of columns in Excel using talend

I would like to know how I can count the number of columns of an excel sheet using Talend

Upvotes: 0

Views: 812

Answers (2)

CleanBold
CleanBold

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

Amine Ben Khelifa
Amine Ben Khelifa

Reputation: 765

If you want to count no. of columns in the Excel file then please follow the below instructions.

  1. Use tfileinputExcel component.

  2. 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.

  3. Now Use second component 'tjavaRow'. Link your excel component through the 'main' row to tjavarow component.

  4. Syn your schema in tjavarow component and put below mentioned code.

System.out.println("Counter ::: "+input_row.excel_heade.getColumnCount());

  1. Now your job will count columns for you.

Note: You can store this counter value in any context variable and can use it.

Thank you

Upvotes: 1

Related Questions