Move first row to last row


This is the sample text.

170766123,itemA66373216
188059977,itemA01502409
169498025,itemA48202024
147855226,itemA11666073

I have a text file that i need to move the first row to the last row.
My problem was im getting an output of comma and the value of first row was missing.

I have attached a photo of sequence and sample text.

@craigmartin

can you share the output of generate datatable activity

@craigmartin

check the thread as reference

@craigmartin

dt.AsEnumerable().Skip(1).Concat(dt.AsEnumerable().Take(1)).CopyToDataTable()

Output:

Column1,Column2
188059977,itemA01502409
169498025,itemA48202024
147855226,itemA11666073
170766123,itemA66373216

image
This is the output of generate datatable activity.

@craigmartin

can you try this once

@craigmartin

Can you try my approach hope it will meet your requirement

Thank you I will look into that.

I’m new to UiPath can you explain about your code how it works? I haven’t tried yet because it really advance to me.

Thank you I will looked into your share. Can you explain why my sequence was incorrect and giving me an output of a comma.

@craigmartin

dt.AsEnumerable().Skip(1).Concat(dt.AsEnumerable().Take(1)).CopyToDataTable()

  1. dt.AsEnumerable(): Converts the DataTable dt into an enumerable collection of DataRow objects.
  2. Skip(1): Skips the first row of the collection.
  3. Concat(dt.AsEnumerable().Take(1)): Concatenates the remaining rows with the first row from the original DataTable.
  4. CopyToDataTable(): Converts the concatenated collection of DataRow objects back into a new DataTable.
  5. The resulting DataTable now has the first row moved to the last position.

@craigmartin

i think the sequnece which you have implememented was correct.

can you debug the process by placing break points and check the output after each activity,So that you can figure it out where it went wrong?

Thank you for detailed information highly appreciated.

image

The first row output is for assign: firstRow = dtFileContent.Rows(0)
The second row output is for Remove Data Row Activity.
The third row is after Add Data Row Activity.

My question is why is the firstRow value deleted even we assign to a variable?