Search code examples
etlpentaho-spoonpentaho-data-integration

How to find columns count of csv(Excel) sheet in ETL?


To count the rows of csv file we can use Get Files Rows Count Input in etl. How to find the number columns of a csv file?


Solution

  • Just read the first row of the CSV file using Text-File-Input setting header rows to 0. Usually, the first row contains field names. If you read the whole row into a single field, you can use Split-Field-To-Rows to have a single fieldname per row and the number of rows tells you the number of fields. There are other ways, but this one easily prepares for a subsequent metadata injection - if that's what you have in mind.