This is CSV Data I want to replace last row data in first row

@Gaurav_Gore

  1. Read the data into Datatable
  2. Use for loop with dt.Columns
  3. Inside use if condition currentitem.ColumnName.StartsWith("A-")
  4. on then side use assign with dt.rows(0)(currentitem.ColumnName) = dt.AsEnumerable.Last(function(x) Not String.IsNullOrEmpty(x(currentitem.ColumnName).ToString))(currentitem.ColumnName).ToString

Hope this helps

cheers

try below steps

  1. read to datatable dt using read csv

  2. use for each loop to iterate through columns dt.Columns as in and type argument as system.data.datacolumn

  3. use if condition as below column.ColumnName.StartsWith("A-")

  4. Use assign activity in then block as below
    left side

dt.Rows(dt.rows.IndexOf(dt.AsEnumerable.SkipWhile(Function(x) not String.IsNullOrWhiteSpace(x(column.ColumnName).ToString)).first)-1)(column.ColumnName)

right side

dt.rows(0)(column.ColumnName)

Later write back the same data table to csv

Hope this helps

Getting this error

@Gaurav_Gore

Can you run in debug and when error comes can you please open the dtwendy and check if it has data in it

May be a screenshot would help…as per error it says all rows are empty

Cheers

if whole colomn are empty then i got error
please send solution

@Gaurav_Gore

In the if condition add this as well

currentitem.ColumnName.StartsWith("A-") AndAlso dt.AsEnumerable.Where(function(x) Not String.IsNullOrEmpty(x(currentitem.ColumnName).ToString)).Count>0

Cheers

image
It’s work but output getting wrong i need last row value but it’s come previous colomn value

did you try the solution i provided?

if there any total blank values in any column then add condition

column.ColumnName.StartsWith("A-") AndAlso dt.AsEnumerable.Where(function(x) Not String.IsNullOrEmpty(x(column.ColumnName).ToString)).Count>0

Regards

@Gaurav_Gore

Can you show the code please…because I tried and I am gettingn as expected

Cheers

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