How to process each item in an excel sheet ?
NB : Without using any kind of loop like" for each row "
How to process each item in an excel sheet ?
NB : Without using any kind of loop like" for each row "
Hi,
for processing each and every item in a sheet, itâs definitely required to iterate over each item atleast once.
Couldnât understand your requirement for not looping. Could you please elaborate?
When you say without using loop, are you trying to read just a single row from an excel file with multiple rows?
It was asked during an interviewâŚ
Here we go. Just use âmacrosâ and call it from UiPath .
please refer this.
Also it depends on what you mean by âprocessing itemsâ. If I want to write the sum of the first two columns into column C I can just Read Range and the add a new column to the datatable with the default value being the formula that add the corresponding relative cells. So I think it depends on the use case.
#triggered
<rant>
(Disregarding for a moment what is the actual âprocessingâ that needs to be done)
Sorry for the slight offtopic and I might be missing the point, but if Iâd be in your position Iâd inquiry the interviewer about why youâd need to do it. Fancy solutions might look impressive during interviews, but using the simplest method (loop) that fulfills business criteria (process all rows) is what gets projects finished.
To quote Joel Spolsky:
They are the kind of people who decide to refactor your core algorithms to use the Visitor Pattern, which they just read about the night before, and completely misunderstood, and instead of simple loops adding up items in an array youâve got an AdderVistior class (yes, itâs spelled wrong) and a VisitationArrangingOfficer singleton and none of your code works any more.
Maybe Iâm âbrokenâ, but if there isnât a good (or at least decent) answer to why youâd want to do something in a way thatâs more complicated and itâs just for complexityâs sake, even if itâs âjust an interviewâ, Iâd probably answer âthere is no reason to NOT do it with a loop thenâ and if they insist try to think of something on the spot or just say âThank youâ and try to finish the interview, because I already know that I donât want to work there (this obviously depends on a lot of circumstances and varies case by case for each person).
Interview works both ways - they get to know you, but also you get to know them - who theyâre looking for and what are they asking tells A LOT about what kind of team you will end up in. If the interviewer isnât a part of the team, and itâs not a âphone 1st step interviewâ then itâs a yellow flag also - people not related to the team should not decide who is hired to it. Itâs too easy to mishire someone if you wonât be working with them, thatâs just asking for troubleâŚ
</rant>
Back on topic:
To add another option - recursive invokes used as a forward iteration method could work too.
But either way most solutions will just mask a loop (or a functional equivalent of a loop) while being vastly more convoluted. Loops are so prevalent in âtransactionâ processing (and in programming generally) for a very good reason.
Sorry for the rant⌠these kind of interview questions just really trigger me Iâd really hope thereâs a good reason why they disallow one of the most elegant solutions that it could be done with.
@andrzej.kniola Have you been to interviews recently ?
The solution for this could be using an Orchestrator Queue to process items without iterating through a loop. any data in the excel sheet can be directly uploaded to the queue or using Read range into a Datatable and Bulk add queue items activity.