Remove a datarow based on a specific criteria

I want to remove those row if the FIN number is less than 11 digits. Does anyone know how to do this? Thank you so much!!!

Input
image

Output
image

  1. Read Excel Data:
  • Use the Excel Application Scope activity to read the data from your Excel file into a DataTable using the Read Range activity.
  1. Filter Rows:
  • Use the Select method of the DataTable to filter rows based on the condition that the value in the “FIN” column is numeric and has less than 11 digits.
    DataTable.Select(“IsNumeric([FIN]) AND LEN([FIN]) < 11”).CopyToDataTable
    This will give you a new DataTable with the filtered rows.
  1. Write Filtered Data to a New Excel File:
  • Use the Write Range activity to write the filtered DataTable to a new Excel file.
  1. Delete Original Excel File:
  • If needed, you can choose to delete the original Excel file after creating the filtered version.

Hey @ndtran85
you can filter datatable.
Try this:
dt = dt.AsEnumerable().Where(Function(row) If(IsNumeric(row("FIN").ToString()), row("FIN").ToString().Length >= 11, False)).CopyToDataTable()

Thank you so much @pikorpa!!! It works!!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.