Icon

ForumQuestion0004 - Write Multiple CSV Files with a Loop

<p>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:<br><br><strong>Read CSV File:</strong> The input dataset is loaded using the CSV Reader, which contains various rows with city names in one of the columns.<br><br><strong>Group by City:</strong> The GroupBy node is used to group the dataset by the city column, generating a unique list of cities.<br><br><strong>Start Loop:</strong> 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.<br><br><strong>Generate Dynamic File Paths:</strong> 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.<br><br><strong>Filter Rows by City:</strong> 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.<br><br><strong>Write CSV Files:</strong> 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.<br><br><strong>End Loop:</strong> The Loop End node closes the loop after all cities have been processed and their respective files have been written.<br><br>This workflow efficiently exports a separate CSV file for each city, containing all the rows corresponding to that city from the input dataset.</p>

Nodes

Extensions

Links