I am able to split the first name and last name into different columns from a full name. However, in my project in some cases some names have middle name (alphabet). How can I exclude middle name (alphabet) dynamically as I have thousands of names in my names’ list? Thanks
Please see the following screenshot for your visibility. Thanks!
dt.AsEnumerable.ToList.ForEach(
Sub(r)
r("FirstName")=System.Text.RegularExpressions.Regex.Match(r("FullName").ToString,"^\S+").Value
r("LastName")=System.Text.RegularExpressions.Regex.Match(r("FullName").ToString,"\S+$").Value
End Sub
)
Thanks a lot, @Yoichi. Yes, the split works for all the scenarios, including the full names with(out) middle name (alphabet). I have a follow up question for you, if you do not mind.
– I do not want to see the column called fullname in the output (result) file, just first name and last name, just split ones. How do I restrict the fullname column from going to output?
– I need all the columns in the input except the fullname in my output (result) file
– Not very much essential but just FYI, I use modern design in my process.
Please advise. Thanks!
However, in my case
I need to use an input excel file that has fullname
and after the data manipulation is sent into another excel file (output). Tried a couple of times…
and it looks like I am missing something important. Please have a look at this screen shot
This error shows the DataTable already has “FirstName” column. Do you read it from Excel sheet? is there already FirstName column? if so, it’s unnecessary to call this activity.
If it’s uncertain the column exists or not, please use If activity to check in advance, as the following.
@Yoichi thanks!
I did the same thing (If) for both First name and Last name and I received the following error for the next activity (Invoke Code). FYI- regardless of the thrown error I can see data loaded into the output file. This issue happens when I use “Remove Data Column” after “Invoke code” activity. One more thing, I was trying to rearrange the location of First Name and Last name to be located in the first and second columns respectively. Thanks!
Can you share whole message as text? Probably we need the first 2 or 3 lines.
(we need text after “Exception has been thrown by…” at the first line in the above image)
RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.ArgumentException: Column ‘FullName’ does not belong to table A1.
at System.Data.DataRow.GetDataColumn(String columnName)
at System.Data.DataRow.get_Item(String columnName)
at UiPathCodeRunner_23e9a0dbe45a4446b0817fe83373eaaf._Closure$__._Lambda$__0-0(DataRow r)
at System.Collections.Generic.List1.ForEach(Action1 action)
at UiPathCodeRunner_23e9a0dbe45a4446b0817fe83373eaaf.Run(DataTable& dt)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)