Skip to main content
Cadet | Tier 2
February 22, 2022
Question

I want to check an excel file and sen an error

  • February 22, 2022
  • 1 reply
  • 73 views

Hi,

I'm trying to build a process for which the bot Check a column and trow an error if:

in a column there are any duplicate data

in some line in that specific column an information is missing.

I tried but is not catching the duplication error. Any ideas?​

    1 reply

    Ashwin A.K
    Navigator | Tier 3
    February 22, 2022

    Hi @zeno gALLI​ ,

     

    The way I would approach this is by connecting to Excel like it were a Database and leverage the SQL operations to my advantage.

     

    SELECT [ColumnName], COUNT ([ColumnName])

    FROM [SheetName$$]

    GROUP BY [ColumnName]

    HAVING COUNT([ColumnName])>1

     

    Then you can check if the DataTable is empty, if so then there are no issues, and if it contains data, that means you have to Throw an exception:

     

    ThrowExceptionIfDuplicate 

    Kind Regards,

    Ashwin A.K

     

     

    Blogs at TheCodingTheory - https://www.thecodingtheory.com