Robotic Process Automation

Expand all | Collapse all

Comparing two data tables & identify new randomly inserted rows

  • 1.  Comparing two data tables & identify new randomly inserted rows

    Posted 4 days ago
    Hey everyone,

    I have two data tables which are both in the same format and have this header row:

    Name 1 I Typ I Station I Name 2

    My question is how I can compare those two data tables to find newly inserted rows in the second data table? I could not find a concrete command for that and the solution I applied in UiPath with a For Each Row does not work here either. How would you fix this?

    Also: the data tables are from a web table via the command "Get Web Table" and the values in the Name 1 column are f.ex. 
    <a class=""dropdown_tab"" onclick=""return show_dropdown('dropbox_112289');"" href=""#"">Name 1 Placeholder</a>
    <ul class=""dropbox"" id=""dropbox_112289"">
    <li><a href=""/bookings/112289"">Anmälningsöversikt</a></li>
    <li><a href=""/booking_steps/112289/edit"">Komplettera anmälan</a></li>
    <li><a href=""/covers/new?booking_id=112289"">Ny anmalan</a></li>

    However, I only need the name (Name 1 Placeholder) and not the whole HTML code. That shouldn't be a problem when comparing the data tables but it is still surprising that the whole HTML code is in the data table. Moreover, my question is also why there is no command to turn a data table into a collection or straight a web table into a collection.

    I hope someone can answer the first question about comparing the data tables, the follow up questions are not that important and only surpised me.

    Thanks a lot

    Jan Lorenz

  • 2.  RE: Comparing two data tables & identify new randomly inserted rows

    Posted 3 days ago
    Hi Jan

    I don't think that there is a command to compare data tables but it should be possible to compare using a For loop. I added a simplified example below.

    defVar --name DT1 --type DataTable
    defVar --name DT2 --type DataTable
    defVar --name vRowIterator --type Numeric
    defVar --name vRowValue --type String
    defVar --name vRowCount --type Numeric
    //# initialise
    addColumn --dataTable ${DT1} --columnname Name --type String
    addColumn --dataTable ${DT2} --columnname Name --type String
    for --variable ${vRowIterator} --from 1 --to 5 --step 1
        setVar --name "${vRowValue}" --value "ROW-${vRowIterator}"
        addRow --valuesmapping "Name=${vRowValue}" --dataTable ${DT1}
    for --variable ${vRowIterator} --from 1 --to 7 --step 1
        setVar --name "${vRowValue}" --value "ROW-${vRowIterator}"
        addRow --valuesmapping "Name=${vRowValue}" --dataTable ${DT2}
    //# verify
    for --variable ${vRowIterator} --from 1 --to ${DT2.Rows} --step 1
        mapTableRow --dataTable ${DT2} --row ${vRowIterator} --mappings "name=Name=${vRowValue}"
        filterTable --where "Name=\'${vRowValue}\'" --dataTable ${DT1} vRowCount=rows
        if --left "${vRowCount}" --operator "Equal_To" --right 0
            logMessage --message "New record found: ${vRowValue}" --type "Info"

    Regarding your question about "Get Web Table": this command is just getting the data in each table cell. If that data is 'simple' then there is no markup in the data table. But in your case, it seems that the table cells are containing 'complicated' elements like list-items so that's the way they will appear in the data table. I assume that you know that you can remove the markup with the 'remove HTML'-option in the "Get Web Table"-command?

    nordine vandezande