Put value into datatable/excel

I have to scrape data from multiple PDF and put the data in a datatable. I am able to scrape data from multiple PDF and put into variable using forloop. How do I put these variableds into the datatable/excel.

For Excel:
Try Write Range, Write Cell activities.

For Database:
Try Connect,Insert,Disconnect Activities

I am able to write the cell value just once (the last run of for loop). I want that for each iteration ,one row is written

Do something like this in the for reach loop

Trying the same , setting a counter , count= 0+1 , Not getting result so debugging now

Hi @sampaddas,

Once you get the text from the PDF, are they multi-lined?

If yes, you could create an array of strings according to the line breaks, e.g:

Once you do it, you are capable to iterate between the lines of the PDF text and then you are able to perform string operations like Substring, Left, Regex (Matches activity), etc.

1 Like

Thanks , worked with the counter !

1 Like

Hi,

For the above case if it is not multilined text file how to proceed further.

waiting for your reply…

Hi @venkatesan,

Text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec faucibus leo elementum varius dictum. Suspendisse ornare euismod tortor, vel lacinia quam rhoncus sed.

In this case, I would suggest you to do the following steps:

Separate the string block from the whole text that contains the information you need using the following code, for example:

var textBlock = text.SubString(0, text.IndexOf("sed.")

  1. In this block try to break them into an array of lines using the following code:
    Dim lines As String() = textBlock.Split(New String() {Environment.NewLine}, StringSplitOptions.None)

  2. Once you have this array you could iterate it to do the necessary operations.

Actually i am getting small text only from pdf for example “amount” this kind of small information only iam retriving from pdf…

I need to update the information from pdf to excel …for this purpose i had created datatable …as of now i can able to fetch data from pdf and insert into excel sheet…

My problem is i need to update data row by row …ie if one row is completed next row data must be updated…

Can you give me some solution regarding this…i need to update data’s row by row into excel or data table

Hi @venkatesan,

Kindly check the example below:
Main.xaml (10.9 KB)

It basically update the ‘Amount’ column from the datatable based on a previous filter, in this case I filtered the datatable based on the Id field. I hope it helps you or at least give you an idea on how to solve your problem.

2 Likes

Thanks for your kind reply acaciomelo…

I have 9 columns(user details) in my data table and more than 50 rows to be filled …since it is user details every row will be diffrent…

I am getting the each user data from pdf and inserting into data table… if one user deatils was filled it must go to next row…i am struk with this iteration process acaciomelo…

Hi @venkatesan, I have attached a sample workflow. .Main (1).xaml

I am using iteration in it. You can implement the same in your case. The idea is to use “Add Data Row” activity in each iteration. You can provide the variables in curly braces in Array Row field of this activity and provide the name of datatable to which you need to add this row to in Datatable field.

I hope it solves your problem.

2 Likes

Hi @venkatesan,

In order to check if the specific column from the datatable was properly fulfilled you may use the following code inside your For each row activity

string.IsNullOrEmpty(row.Item("Amount").ToString)

If the row was already inserted you could filter the datatable based on a specific column like I did on the previous example that I have attached, otherwise you could use the Add Data Row activity with the information needed already inside it, like @Prakshi_Tyagi showed to us.

Please download the example that I have attached and try to understand what I have done there and maybe it will help you.

1 Like

Hi prakshi

I am getting user details from diffrent pdf and inserting into one data table. Since iam getting details from diffrent pdf file i was not able to proceed further…

i am ok with fetching data from single pdf and inseting into data table…

My problem is i need to get data from 10 pdf files and insert into one data table…

Thanks acaciomelo i am working on this

1 Like

thank you very much prakshi i got the result… i am really happy for your quick response and helped me to get solution for my problem

1 Like

thank you very much acaciomelo i got the result… i am really happy for your quick response and helped me to get solution for my problem

4 Likes

Hi vvaidya, I am trying to do something similar and getting a compile error when adding the ‘count’ variable to the cell we wish to write in. It says "Option Strict On disallows implicit conversions from String to Double.

Can you help me figure out what I am doing wrong?

Thanks,
Chris