activities
latest
false
UiPath logo, featuring letters U and I in white
Productivity Activities
Last updated Nov 15, 2024

Verify CSV Files

The example below includes two automation processes. The first process identifies a value and appoints a status to it, while the second automation process incorporates the first one, analyses the data from one file, processes it and stores it into another file.

The main activities used are Read CSV, Write CSV and Append To CSV. You can find these activities in the UiPath.Excel.Activities package.

This is how the automation process can be built:

  1. Open Studio and create a new Process. The process is automatically named Main.
  2. Go to the New tab and select Sequence.

    • In the Name field write Process.
    • Select the same location as the one for the Main process.
    • Select Create.
  3. In the Workflow Designer, select the Process tab.
  4. Drag a Sequence activity to the Workflow Designer.
  5. Add an If activity inside the Sequence.

    • In the Properties panel, add in the Condition field the syntax io_TransactionItem("Phone Number").ToString.EndsWith("2").
    • Add two Assign activities, one for the Then field and another one for the Else field.
    • For the first Assign activity, placed in the Then field, configure the Properties as follows: add io_TransactionItem("Status") in the To field and "Failure" in the Value field.
    • For the second Assign activity, placed in the Else field of the If activity, configure the Properties as follows: add io_TransactionItem("Status") in the To field and "Success" in the Value field.
      Note: Go into the project folder and create two new folders named Input and Output. Inside the Input folder, add the .csv file from which the data is read.
  6. In the Workflow Designer, select the Main tab.
  7. Drag a Sequence from the Activities panel to the Workflow Designer.

    • Create the following variables:

      Variable Name

      Variable Type

      Default

      InputFile

      String

      "Input\ToBeProcessed.csv"

      OutputFile

      String

      "Output\Results.csv"

      ProcessDT

      DataTable

       
  8. Add a Read CSV activity inside the Sequence

    • In the Properties panel, add the variable InputFile in the FilePath field.
    • Select the IncludeColumnNames check box. This specifies that the first row from your file contains the column names.
    • Add the ProcessDT variable in the DataTable field.
  9. Drag a For Each Row activity under the Read CSV activity.

    • In the Properties panel, add the ProcessDT variable in the DataTable field.
  10. Drag a Sequence in the body of the For Each Row activity.
  11. Add an Invoke Workflow File activity

    • In the Properties panel, add the file location of the workflow you want to invoke in the WorkflowFileName field. In this case, the path is "Process.xaml", as the file is in the project folder.
  12. Drag an If activity in the main sequence, below the For Each Row

    • Add in the Condition field the next syntax file.Exists(OutputFile).
  13. Drag two Append To CSV activities, one in the Then and one in the Else fields.

    • For both activities, set the FilePath as OutputFile and in the DataTable field add the variable ProcessDT.
  14. Run the process. Once the automation process is complete, you have a new .csv file in the Output folder, named Results.csv.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.