This workflow automates the process of exporting rows from a dataset into individual CSV files based on unique city names in the city column. The steps are as follows:
Read CSV File: The input dataset is loaded using the CSV Reader, which contains various rows with city names in one of the columns.
Group by City: The GroupBy node is used to group the dataset by the city column, generating a unique list of cities.
Start Loop: The Table Row to Variable Loop Start initiates a loop, where each iteration focuses on one city. This node creates variables from the unique city names.
Generate Dynamic File Paths: The Create File/Folder Variables node is used to generate a dynamic file path and filename based on the current city. Each file is named according to the city in the current loop iteration.
Filter Rows by City: A parallel branch with a Row Filter node is set up to filter rows that match the current city from the loop iteration. This node takes the entire dataset and filters it to only include rows for the city being processed in that iteration.
Write CSV Files: The filtered rows are then written to individual CSV files using the CSV Writer node. The file paths and names are dynamically generated from the city names.
End Loop: The Loop End node closes the loop after all cities have been processed and their respective files have been written.
This workflow efficiently exports a separate CSV file for each city, containing all the rows corresponding to that city from the input dataset.
Workflow
ForumQuestion0004 - Write Multiple CSV Files with a Loop
External resources
Used extensions & nodes
Created with KNIME Analytics Platform version 5.3.3
- Go to item
- Go to item
- Go to item
- Go to item
- Go to item
- Go to item
Legal
By using or downloading the workflow, you agree to our terms and conditions.