dr1992
September 6, 2022, 11:53am
1
Hi there,
I am having the bot scrape two separate columns from a portal which do not have headers (the portal is quite badly designed!); what I’d like to do with them is merge them to be side-by-side, but when I try and do so, it just appends them.
I have tried to create a new datatable to add them to separate columns, but can’t seem to get it right.
Eg:
scrape 1:
Product1
Product2
Scrape 2:
Price1
Price2
Result:
Product1
Product2
Price1
Price2
Required:
Product1 Value1
Product2 Value2
How can I go about doing this? Apologies for the basic question here, I’m still not a pro with UiPath aha. Thanks for your help.
ppr
(Peter Preuss)
September 6, 2022, 11:59am
2
Find some starter help for a side by side merge
@Vi_ciel
have a look on following flow, supporting different rows count e.g. on dt1, dt2
[grafik]
With datatable merge details:
[grafik]
input / output:
[grafik]
Kindly note: in case of multiple datatables will have the same column name, it has to be handled in advance by making the col names unique
find starter help here:
SideBySideMerge_AlsoDifferentRCnts.xaml (10.8 KB)
SideBySideMerge_AlsoDifferentRCnts.xaml (10.8 KB)
2 Likes
TrinadhB
(Boda Trinadh)
September 7, 2022, 7:16am
3
If you are scraping the data into two Datatables and want to merge sid by side. You can try this-
Scrape1(in Datatable1) and scrape2(in datatable2)
Add data column to Datatble1
For each row in Dtatatble1
assign values from datatable2 to datatble1 using Index
ex: item(1) = datatable2.rows(idx)(1).tostring
dr1992
September 7, 2022, 9:15am
5
Hey Peter,
Thanks for reply, the last assign gave me this error: Assign: Input array is longer than the number of columns in this table.
ppr
(Peter Preuss)
September 7, 2022, 9:22am
6
just share with us your implmentation, so we can check for inconsitencies when helper xaml was integrated
dr1992
September 7, 2022, 9:46am
7
This sounds like it might work, but I’m a bit confused as to final point and example - do you have visual I could refer to, by any chance? Thank you!
dr1992
September 7, 2022, 9:47am
8
I pretty much copied exactly what you did, but changed the result to ‘pDT’ (new blank data table) and the other two to merge pColDT1/2.
ppr
(Peter Preuss)
September 7, 2022, 9:53am
9
dr1992:
I pretty much
dr1992:
but changed the
feel free to let us inspect or crosscheck working helper xaml against your individual modification
issue is about that the dimension of the row array is not correct. so the column schema merge part should be reviewed at your custom modelling
dr1992
September 7, 2022, 10:12am
10
I meant: I copied it exactly but just changed variable names.
The source in merge data table is ‘item.clone’.
Maybe it has something to do with the lack of headers (you have some in the one you built)
ppr
(Peter Preuss)
September 7, 2022, 10:17am
11
set a breakpoint at the for each
run debug file and get paused by the breakpoint from above
type into the immediate panel:
pCol1DT.Columns
pCol1DT.Columns
and share with us the output
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
mabye some col names are the same within the two datatables and get consolidated by the datatable clone schema merge
1 Like
dr1992
September 7, 2022, 10:25am
12
I think you are correct again, sir. How do we remedy this?
ppr
(Peter Preuss)
September 7, 2022, 10:29am
13
How about following?
dtData - replace with your second DT: pCol1DT
item.columnName.Trim = item.columnName.Trim & “_B”
so we mark the second dt cols to avoid duplicate names. Later we can also change as needed
dr1992
September 7, 2022, 10:56am
14
ppr:
item.columnName.Trim
I managed to just add an assign after the new DT assign of ‘pCol2DT.Columns(0).ColumnName’ = “Column2” and that has worked.
Thank you very much, your help is always appreciated!
system
(system)
Closed
September 10, 2022, 10:59am
16
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.