Merging CSV Files into an Excel File
  • 29 May 2023
  • 2 Minutes to read
  • Dark
    Light

Merging CSV Files into an Excel File

  • Dark
    Light

Article summary

Example Lab Article
While Example Lab projects are resources for public use, articles and assets are not actively maintained. Screenshots and features are from the specified version below. These references may become dated as new versions are released.

Overview

Example Lab Details

Version6.18.0
Root FolderExample Lab - Merging CSV Files into an Excel File
Modules None
DependenciesNone

This Example Lab demonstrates how to merge CSV files into a single Excel file by saving them into different worksheets and how to download the Excel file in a Form.


Explanation

The Create New Excel File step creates the Excel file for saving the CSV files' data. This project requires the user to input CSV files to the Parent Flow labeled "CSVFiles" at the start step of this example Flow. Example CSVs are included within the Project Download. The ForEach step accepts "CSVFiles" as its input, so it loops given the number of CSV files uploaded by the user. Each loop passes the file into the provided "Merge CSV" Flow which transfers the data from each file row by row into the created Excel file. 

Within this Flow, the Create Data and Add steps create a counter differentiating one row from another. The Add Work Sheet step creates a worksheet in the Excel file to save this CSV's data. The Flow then begins to gather the data row by row due to the For Each Excel or CSV step, while the Set Values in Row step maps each CSV row's data into its own Excel row. This example maps only two columns of data for each row, but if a user wishes to transfer more columns of data, then select the Set Values in the Row step, locate "New Values" under Inputs, and then click Add. A new item will appear below. Change that item's input mapping to Select From Flow, then map it to the next appropriate field in the current row. For example, "Current Row.Field03.TextValue" reads the CSV's third column of data, etc. Once this loop finishes, the Update File with Data step saves all the data taken from the CSV into the Excel file. Finally, the end step outputs the result of the Update File with Data step for the Form located in the Parent Flow. The generated Excel file may be downloaded from this Form.

Reference Articles



Project Download

The examples attached were developed to be instructional and were not developed as officially supported components. For more information or to engage our service team to develop fully supported, production-quality solutions, please contact services@decisions.com. Import the project below to a Decisions environment on version 6.10.2 or later using our Importing/Exporting article.




Was this article helpful?