Manage CSV Files
By using this workflow, you can automatically read a .csv file and also append data from one .csv file to another .csv file.
This example illustrates how to create an automation process that uses the Read CSV and Append To CSV activities. You can find these activities in the UiPath.Excel.Activities package.
To exemplify how to use these activities, we have created a sequence that includes a Read CSV and an Append To CSV activity.
This is how the automation process can be built:
- Open Studio and create a new Process.
- Drag a Sequence from the Activities panel to the Workflow Designer.
note
Add your .csv files to the project directory in order to be able to run the entire process from the same place.
- Drag a Read CSV from the Activities panel in the previously created Sequence.
- In the Properties panel, add the full path of the file you want to read the data from to the FilePath property. In this case you can write as a path
Environment.CurrentDirectory + "\A.csv". - Select the IncludeColumnNames check box. This way, when running the process, the first row in the
.csvfile will be considered to contain the column names. - Create a new
DataTablevariable called DT. - In the Properties panel, add the newly created variable to the DataTable property field.
- In the Properties panel, add the full path of the file you want to read the data from to the FilePath property. In this case you can write as a path
- Drag an Append To CSV activity from the Activities Panel and place it below the Read CSV activity.
- In the Properties panel, add the full path of the file you want to read the data from to the FilePath property. In this case you can write as a path
Environment.CurrentDirectory + "\B.csv". - In the Properties panel, add the DT variable to the DataTable property field.
- In the Properties panel, add the full path of the file you want to read the data from to the FilePath property. In this case you can write as a path
- Run the process. Data from file A is read and appended to file B.