Skip to content

Remove Duplicate Action: removeDuplicate

The removeDuplicate action under the CSVHandle function removes duplicate rows from a CSV file based on a specified column. The resulting file, with duplicates removed, is saved at the specified output path. The operation result (true/false) is stored in a variable for further use.

Note: Ensure that the file being used is not open during the execution of the Case to avoid errors or conflicts.

Example: Suppose you have a CSV file named EmployeeRecords.csv, located at C:\Data, with the following data:

scrn-remove-duplicate-csv-with-duplicate-records
CSV with duplicate records

You want to remove duplicate rows based on the EmployeeID column and save the updated data in a new file named UniqueEmployeeRecords.csv.

Steps to Configure:

  1. Select Set a Variable Value from the Action dropdown.
  2. Enter a variable name in the Element Key field (e.g., DuplicateRemovalStatus). This variable will store the result of the operation (true/false).
  3. Click on Form, select Functions, and choose CSVHANDLE.
  4. In the Cmd field, select removeDuplicate and provide the following parameters:
    • FPath: Specify the path to the source CSV file (e.g., C:\Data\EmployeeRecords.csv).
    • OutPath: Specify the path to save the updated file (e.g., C:\Data\UniqueEmployeeRecords.csv).
    • ColumnName: Enter the column name to identify duplicates (e.g., EmployeeID).
  5. Click Save.
scrn-remove-duplicate-command-tabular-view
Tabular View
scrn-remove-duplicate-command-card-view
Card View

Outcome on Execution:

  • The updated CSV file (UniqueEmployeeRecords.csv) will contain the following data:
scrn-remove-duplicate-command-csv-with-unique-records
CSV with unique records
  • If the operation is successful, the variable (e.g., DuplicateRemovalStatus) stores true.
  • If the operation fails (e.g., invalid file path or column name), the variable stores false.
  • This variable can be referenced in subsequent automation steps using the syntax ${VariableName} (e.g., ${DuplicateRemovalStatus}).

Back To Top