Hello there. I have created in a for each 10 variables with splitted text for each datascrape (from a website) and I would like to append this data to excel. Each variable should append in a different column in the excel file. What is the easiest approach?
1.Firstly Take a build data table activity and create the 10 columns in it.
2. Use add data row activity inside the loop and pass the 10 variables in the add data row activity and mention data table
3.Out of for each use write range workbook activity to write to excel
Hi @tech2 ,
We could Prepare the Datatable Table Columns (10 Columns as 10 variables) using Build Datatable activity at the beginning.
Then after each Data Scrapping, collect the variables and use it inAdd Data Row
Activity.
Use the Prepared Datatable variable as the Datatable and in ArrayRow
property we can add all the 10 variables like the below Expression :
new Object(){var1,var2,var3,var4,......}
thank you. How do i ‘pass’ the variable into it. Is it just typing the name of thevariable into the datatable field?
Hi @tech2
In Add Data Row you need to pass in ArrayRow and you need to pass your varaiables as and array
{var1, var2, var3}
Hope this may help you
Thanks,
Srini
You can mention like this in add data row activity
for suppose i have taken like this …you can take your columns by separating with (,)
{strOutPut1,strOutPut2,strOutPut3}
Note : - before the add data row activity you can do splitting the text and add to separate variable and pass that variables in the add data row activity which i have shown above
@tech2
i did that, but i get the following error:
For Each Row in Data Table: Collection was modified; enumeration operation might not execute.
you can try this way then
1.You can create a build data table with the 10 columns and variable is = dtfinal
2.Extract the data form web and out put = datatable1
3. And add to 10 variable inside the loop and use the add data row activity and give data table
out ass dtfinal.
4. so every time it will add the rows to dtfinal
5. use the write range activity and pass the dtfinal to output
Hi @tech2
Try This Workflow:-
1. Build Data Table
- Add 10 columns to YourDataTable (e.g., Column1, Column2, ..., Column10)
2. For Each
- Iterate through your data source
3. Add Data Row
- ArrayRow: {Var1, Var2, Var3, Var4, Var5, Var6, Var7, Var8, Var9, Var10}
- DataTable: YourDataTable
4. Write Range
- Excel file path
- Sheet name
- DataTable:- YourDataTable
thanks. But, I didn’t create a datatable for the webscrape because I couldn’t cath some elements. So i used the ‘gettext’ activity. That works. And then sended the gettext variable to GPT en stored the output in a new variable. And then I splitted the output in 10 different variables. So my begin isn’t a datatable, it is just the 10 variables. What is the best approach?
you are getting the data by get text activity and splitting the text into 10 variables
1.So just take a build data table activity and create columns with 10 variables
2.after that use the add data row activity and mention like this in add data row activity
{strOutPut1,strOutPut2,strOutPut3}
Note : - just i have taken the sample columns so you can take your columns
it works. But it overwrites every time the first row. How do i set the write workbook range to append rows so i can create the excel file for all datarows? I can’t find an ‘append’ option in the Add Data Row activity?
Then you can use this Append Range Workbook Activity
Note 1 : - below the add data row activity you can use Append Range Workbook Activity
Note 2 : - if you need the data in excel sheet then end of the loop you can use the write range workbook activity
thank you so much @Praveen_Mudhiraj for you clear explanations. You are a real valuable asset to this forum!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.