Read row that have data?

Hello.

I have data as below.

I want to read data column B , C in row that first row that column A and D not blank .

Please guide me about it.

@Stef_99

Just read whole data into datatable using read range

Then use a filter datatable and add filter on column A and column D to be not empty…the rows remaining are the non empty rows

Cheers

Hii @Stef_99 follow these steps

  • Read Data from Excel
  • Use “Read Range” activity (inside “Excel Application Scope”).
  • Set the output variable to dtData.
  • Find the First Row Matching the Condition
  • Use “For Each Row in DataTable” activity:
    use the below vb expression

Not String.IsNullOrEmpty(CurrentRow(“No”).ToString.Trim) AndAlso Not String.IsNullOrEmpty(CurrentRow(“Status”).ToString.Trim)

if the condition is true

nameValue = CurrentRow(“Name”).ToString
idValue = CurrentRow(“ID”).ToString

later on Use “Break” activity to exit the loop after finding the first matching row.

cheers!!

Hi @Stef_99

You can also try the LinQ

dt_input = dt_input.AsEnumerable().Where(Function(row) String.IsNullOrWhiteSpace(row("Staus").ToString()) AndAlso String.IsNullOrWhiteSpace(row("No").ToString())).CopyToDataTable()

And if just want the columns Name and Id then use


dt_input = dt_input.AsEnumerable().Where(Function(row) String.IsNullOrWhiteSpace(row("Staus").ToString()) AndAlso String.IsNullOrWhiteSpace(row("No").ToString())).CopyToDataTable().AsDataView.ToTable(False, "Name", "ID")

Hope this helps

1 Like

@Somanath1
How to get number row that found first tow?

Hi @Stef_99

Use the below LINQ expression to get the rows which are Column A and B are not empty,

dt_Output = dt_Input.AsEnumerable().Where(Function(row) Not( String.IsNullOrWhiteSpace(row("No").ToString) AndAlso String.IsNullOrWhiteSpace(row("Status").ToString))).CopyToDataTable

The above expression will filter the rows and keep first row in dt_Output as per your Input data.

Hope it helps!!

If I want to read data in row and stamp result in each row.

How to guide me about it
.

Can you share your expected output data, then we are able to understand your query clearly… @Stef_99

@mkankatala I have data input1 as below.

row No1 column Status have data go to next row that status = blank
found row2 status = blank → read data in row for checking in web —> stamp result in column Status

@Stef_99

Try this workflow

Read the input excel to the datatable dt_input

Difine the condition for the while according to your use case

emptyIndex = dt_input.AsEnumerable().ToList().FindIndex(Function(row) String.IsNullOrWhiteSpace(row("Status").ToString()))
dt_input.Rows(emptyIndex)("Status") = webOperationResult

I tried with a sample input and it works

Hope this helps!

1 Like

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