Add header row to top of existing data datatable

Hi,

Im having issues adding a row to the top of a datatable. I originally “read range” the xlsx into a datatable and the headers for the columns were there. however, I needed to transpose the datatable to move the existing 2 rows of 24 columns into 2 columns of 24 rows. this worked but in the process, it removed my header row. So now when I’m converting the datatable to a dictionary to upload as a single transaction item in the orchestrator queue I’m unable to reference the Column names. Any know how to add a datatable row to the top of the datatable instead of appending it to the bottom?

@Jcircuit13
which row do you want to convert to the header? the first row or last row?

and do you want that row deleted after its converted to header?

Hi @Jcircuit13 ,
I think your problem would be solved if you uncheck the Add Headers property of your read range
image

In this case your header will be read as a normal data, and the transpose logic would work on your 1st row as well.

Let me know if this helps

Thanks,
Nishant

I do not want to convert to a header I need to add a row to the top as the existing first row contains needed values.

If I uncheck “Add Headers” it adds an extra column and still does not fix the issue.

image

@Jcircuit13 ok got it

please follow this thread to change name of headers name

Hi,
You could delete the 1st column after transpose. There is an activity for this. And this way you will get the transposed data

Well this semi-worked however it has now replaced the first row containing a value I need to upload with the names of the columns I specified in the assigned field.

This is still cutting off the first value when adding to the dictionary. Here are some screenshots.


I have resolved this.

By adding a column to the end of the original datatable before the transpose with the values of Column1 and column2. Then use the “Datatable Set Ordinal” Activity from the UiPathTeam.DatatableSetOrdinal.Activity Package I was able to set the index of the newly created column to 0 making it the first column. Then I transposed the original datatable with the “Transpose Datatable” activity from the NovigoSolutions.trasposeDataTable.Activities Package.

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