Copy row before deleting it excel

good afternoon
I have a problem
and I read an excel through , and then through I extract the value that interests me with , then through I check if my data that I extracted with < get row item> have a certain value, for example I will put it “has ruc” in any case if it detects if there is this value and removes it from the excel by means of> delete rows>
but before that I want to save it in another excel, I just can’t find a way to do it
Do you have any suggestions?

uipath forum 6

@ppr
@Jarzzz
@Palaniyappan

help

1 Like

please post a sample data excel and description of expected output
Currently I dont understand all requirements from your description

Thanks

2 Likes

Clientes.xlsx (13.4 KB)

HI
I want to delete the value called “TIENE RUC”, and at the same time I want to save that data in a separate excel

@ppr

@borismh you can do as follows:

System>File>Workbook> Read Range to read your excel sheet


Here you enter full path+ file name of your Excel file, SheetName and leave “” to read the whole Sheet. You also need to create a datatable variable in the Output, and click Add Headers.

Step 2 is to filter the datatable,

Step 3 is to System>File>Workbook>Write your filtered datatable to a new Excel file

Try this and see if this is what you’re looking for.
All the best!

2 Likes

@borismh
have a look on this demo xaml
borismh_deleterow.xaml (8.3 KB)

Core Task is implemented. Writing to Excel you can incorporate with write range activities

3 Likes

@ppr

I don’t understand your workflow very well
could you explain me

@borismh

See the attached…copyRowDataAndDelete.xaml (25.7 KB)

  • Add the same file location to Excel Application Scope - Clients Read (initial read) and Excel Application Scope - Clients Saved (Overwrite)
  • Add a file location to Excel Application Scope - Client Removed (Removed)

You can remove the assign count from the workflow, was used for testing =D

1 Like

@borismh

  • Deleting a datarow while iterating with a for each row will throw an error, due the sequence of datarows is changed
  • CopytoDataTable will throw an error, if no rows are returned by the statement

In general your requirement could be done with two filter statements as well. I used for second part dataset method except

Filter all rows containing TIENE RUC in the column Comentarios
dtData.AsEnumerable.Where(function (r) r(“Comentarios”).ToString.Contains(“TIENE RUC”)).ToList
returning a list(Of DataRow) - Variable: drTieneRuc

with a check if Datatrows are returned: drTieneRuc.Count >0
we do create a datatable: dtTieneRuc = drTieneRuc.CopyToDataTable

Now we want to retrieve all rows from the origin datatable that are not containing TIENE RUC in the column Comentarios

here we used the except statement:
dtData.AsEnumerable.Except(drTieneRuc).ToList and returning a list of datarows

same as above we do check if datarows were returned and if Yes we copy it to a datatable:
dtFiltered = drFiltered.CopyToDataTable

2 Likes

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