How to merge three datatables together and save the result in an excel sheet

datatable
excel

#1

Hi to all! I’m making an automation process that, through a code read from an excel table, compose an url and open the browser with this url (i have a lot of this codes, then part of the process is putted on a For Each statement).
In this page i could have a table with 3 column, and i must export those data to another excel sheet. As far as i know, the only way to save this data is with the “DataScraping” tool.
What i have done is to set three “Extract Structured Data” tools, and everyone of them save a column of the table from the browser in a separate datatable (they are working and i’ve verified the result with some message boxes).
Now i don’t know how to merge these 3 datatable (coloumn) together. What i’d like to do is to have another datatable that at every iteration collect everything. At the end i’d like to save all this datatable in my excel sheet.

Can you help me to find a smart solution? Thanks and best regards!


#2

Aren’t you able to extract the entire Web Table into “Extracted Structured Data” using Data Scraping?

To join datatables, you can refer this


#3

No, probably because of the way in which the tabel is done on the website. If i use the Data Scraping and select the first and the second cells in the same row, it says that cannot recognize the pattern because they have a different tag. The only way i’ve found to access to this data is selecting it by column. [quote=“vvaidya, post:2, topic:4067”]
To join datatables, you can refer this

Join Two DataTables

@tobor Check the attached solution. Hope it helps. JoinTables.xaml (10.4 KB)
[/quote]

Thank you very much! It looks like the solution that i was finding! Can you explain me it a little (only for knowledge…i’ve not understand why there is the Assign…)? I don’t have primary keys on my datatable, will it be working? Tomorrow i’ll try with my data.
Thanks for now!:+1:


#4

Can’t really help regarding datascraping unless I see the web table.

Actually I have a better idea regarding Datatables to excel and there is no need of mergining, why don’t you directly write your each datatable into Individual columns into excelsheet use write range? You just need to mention Cell (A1,B1,C1) in write range activity from respective datatables.

Attached is the solution. Hope it helps.

JoinMultipleTables.xaml (12.3 KB)


#5

This is an example of the table that i’m using: http://www.reportaziende.it/codiceAteco.php?codiceAteco=01.11.10

As you can see the url ending with a code made of 6 number separated by a dot. I have about 1300 of this codes and for each one i must open the url and save the content of the table, and put them into excel.

This solution is perfect! Thank you very much! In this way i can save some steps and make the execution faster. But how can i handle the iterations? Probably i must use a variable that take care of the number of result inserted in excel, and calulate at every step the cell where to start again? I think that if i put your solution in a “for each” statement, it will overwrite the result at every step, am i wrong? Thank you very much again!


#6

Try Append Range

https://www.uipath.com/activities-guide/excel.append-range


Merge multiple excel sheets into single excel sheet (with multiple spreadsheets)
#7

I’ve tried this solution and probably it’s better. I’ve also find another solution to take the three column togheter with a single data scraper: After selected the first column, if you press the button “Extract Related Data” you can select the second column and so on, then with a single operation you can extract the entire table! I’ve made an example and it was working, but after that now i don’t know why it is throwing the exception on the image:

I don’t know if it is related to Excel, to UIPath or o anything other! I’ve tried to remove the Write Range, with the Append Range, and it’s the same! Have you ever seen this error? Thanks


#8

Most likely your datatable is null (not initialized)


#9

Ok, then i suppose that the problem is with the data scraper. I must add some “Output datatable” and “Message Box” to see if there is data inside the data table generated from the data scraper. I’ll let you know


#10

It seems that UIPath is slowly crashing everywhere! now i’m not able to make new data scraping! i have those errors when i try to select the component that i want to extract!


I’ve already check the MSDTC settings following this link:
http://www.codepartners.com/Blog/TabId/110/PostId/139/what-to-do-when-error-hresult-efail-returns-from-a-call-to-a-com-component.aspx
but nothing is solved…i’m facing too many errors using UIPath! I’ve already tried to reinstall everything, what can i do?? thanks


#11

I’ve found the problem, it was related to the extension with google chrome. It seems that is wasn’t installed well…now it works without problem!