Combine several Excel sheets on Knime
Introduction:
Today, we are going to approach a particular scenario that can appear boring but becomes simple to solve once we settled our logic.
Letâs suppose that we must analyze the sailing evolution of a company on the last three years.
The sailingâs historic is to find on an Excel file, that combines over 36 sheets (each sheet contains the sailings of a given month or year).
To start the analyze, we must then group our different sheets into a unique one.
Doing it manually, is an option but when the number of sheets is as high as it is in our case, it is more judicious to use KNIMEâs functionalities. Letâs continue!
Inputs:
Youâll receive this Excel sheet as to proceed to our analyze.
It contains 36 sheets grouping sailings from 01-2020 to 12-2022.
How to proceed?
To combine our different sheets, 4 steps are necessary:
- Supply an Excel file, containing sheets/tabs that we want to combine.
- Convert the Excel sheets into variables and create a loop.
- Read the sheet corresponding to the actual variable.
- Keep data of the sheet that had just been read and skip to the next variable.
The loop arrives to its end when all the variables had been browsed.
Step by step:
Now that we have incorporated the logic behind our method, it is time to build our workflow:
Step 1:
Double-click on the node Read Excel Sheet Names to give the location and the file which we are working with. That node will have 2 output columns: Path ( location of the sheet ) and Sheet ( appellation of the sheet ).
Yet it is the Sheet column that is important since it will be converted in the next step, into a variable.
Step 2:
The configuration of the node Table row to variable loop starts :
The green box is the location where we insert the columns that we want to convert into variable.
In our case, we want to extract data for each sheetâs name in the file. We then need the sheetâs name, in that case Sheet, to be in the green box to be the variable that leads to the loop. Now that we are configured, we can execute the loop.
Step 3:
Now, we are going to configure the Excel Reader loop.
First, we are going to supply the file from which we want to extract data, then we are going to give the variable that contains the names of the sheets we are trying to combine. To do so, we need to click on the Flow Variables tab.
Click on Settings then select sheet in sheet_name as it is shown:
Step 4:
Last, and easiest step, it is now about configuring the Loop End according to your preferences.
Result:
Now that all our nodes are configured, we can execute our workflow.
Once the loop done, the final table should look like this:
Conclusion:
The transformation of the sheetsâ name into variable and the creation of a loop are the solution when you end up working with that kind of data. Your time is too precious to waste it on repetitive and tedious tasks when Knime offers functionalities that allows to automate them!
Author Profile
Latest entries
- News17 August 2022« Data driven marketing », what does it stand for?
- News25 July 2022[News] Tableau and Salesforce: CRM Analytics
- News18 July 2022Data Design – Make your data stunning
- How To11 July 2022Combine several Excel sheets on Knime