Scrape table from web then add the text to a word doc

Hi Guys. I can successfully extract a table of data from a web page. I can also write it to CSV. What I need to do now is take this data and insert it into a pre-formatted word document. I dont know how to do this. Can somebody please help?

2 Likes

Hi Nic,

Need to know what is the pre-formatted document? Can you please share the screenshot of the pre-formatted document .

Hi Nikitha, the document is just a word doc. You can consider it as a blank word document. I plan to add headers etc. later.

I am not sure how to open a word document, and add the data table

My code is limited to the following (i hope you can see the screen shot)>

Thank you!
nic

Hi Nic,

Install the package UIPath.word.activities which helps to work in word automation.

Steps to be followed.

  1. Once you extract the structured data to csv file just open the csv file and select all copy to clipboard
  2. open the word document using word application scope and paste the copied data in word document.

scrape_datatable.xaml (20.9 KB)

Thanks Nikitha.

There is a problem with your code at the end, and I cannot see you opening up word.

Also I dont see how you are calling excel in this screen shot either - can you please explain? It looks like you are using Selectors to open excel.

Thank you so much.
Nic

Hi @Nic

she is using Excel scope activity and at that time she is passing an excel name. this activity will check for that named excel file otherwise if it is does not exists then it will create that file with passed name there.

what she did is , she first extract the table data into a csv file then by using excel scope activity she is reading that file again.

*Note- If you are using her workflow then before run please make changes in file path and make sure that path exists… if you will only pass tha file name with extention then it will check in the root directory(where workflow exists).

Let me know if any other information you wants on this. :slight_smile:

Regards…!!

1 Like

Hi @Nic

Please find the updated code attached .
Main logic is:

  1. copy the extracted data from csv file.
    2.paste it in .doc file.

Please check and let me know if your facing issue still.

<a class=“attachment"href=”/uploads/default/original/1X/884b6d0e47393ffdab7eca5b7da31371e68e5df7.xaml">scrap_datatable.xaml (20.7 KB)

Thank You

2 Likes

Hi @nikitha.hanumanthara,
Just slight recommendations on your above code. :slight_smile:

  1. You can use Word Application scope instead of using open word document because it will open the document and keep it open after doing the operation which is not recommended. You are not saving the word document after writing also. If you will use Word Application scope, then it will open the document and close it after saving automatically.
  2. Else everything is correct.
    Thanks.

Hi @jibanjyoti

I have used word application scope

Please find screenshot below
.

So that it will Open and save the document automatically.

Thanks

1 Like

Hey guys! This is working now! I did not have all my packages updated. Thank you so much for your help.
Nic