Data scraping activity and wrong headers

When I use the data scraping activity on my table it doesnt recognize the headers and instead I get headers like this:

Column-0, Column-1 and so on.

The headers I want appear on the row under.

I would rather not use write range acitivity with add headers unchecked and the read range again with add headers checked. This slows down the process beacuse it needs to save a file for every transaction.

Is there any other way?

Can I make the data scraping activity extract the table but use the second row as columns?

Hi @atomic

I don’t think all web tables exhibit similar behaviour in scraping header row as the first data row. If the headers and data have similar font or the headers are not really distinct, it’s possible that it is scraped as data row.

If you want to avoid write range and read range, you can manipulate the datatable object itself.

  1. For Each → column in datatabale.Columns
    column.ColumnName = datatable.Rows(0)(counter)
    where counter → row index of the for loop
  2. After all columns have been renamed, use Remove Data Row activity to discard the first datarow from the datatable.

Treat this as mostly pseudo-code, so you may need to tweak it to run successfully.
But I hope this approach solves your problem. Let us know if you face issues with this method.


1 Like

I did try remove data row but again, write range activity generate them again.

this issue so annoying.

Hi @irahmat
Sorry about the late reply to this post.
The Write Range activity accepts a datatable.

The two most probable causes that Write Range activity still contains the original scraped data are:

  1. Your Remove Data Row didn’t have the desired effect on the datatable object (i.e. the data row not being removed as expected) OR
  2. You are passing the original data table object instead of the updated/modified one for the Write Range.

Just before you try ‘Write Range’, either add a debug pointer and inspect the table, or use ‘Output Data Table’ activity to get table converted to a string and print it on console using Write Line or Log Message.

See if the datatable going into the Write Range step has correct data.
I hope this helps.

1 Like

Thanks, that helps and now I already used to about this issue.

1 Like

Hi @irahmat, I am also stuck here and new to UiPath. Could you please help me where to write the code to add the column names.