I used ‘matches’ to get a specific text from a big content and enclosed this into a for loop for fetching multiple text from multiple contents.
Now im trying to save these regular expression output into a datatable so that i can input it to an excel file but facing the below error. This error occurs at ‘Add Data Row’ activity. Kindly help. TIA.
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: Unable to cast object of type 'd__971[System.Text.RegularExpressions.Match]' to type 'System.IConvertible'.Couldn't store <System.Linq.Enumerable+<CastIterator>d__971[System.Text.RegularExpressions.Match]> in Email Ids Column. Expected type is Int32. ----> System.InvalidCastException: Unable to cast object of type ‘d__97`1[System.Text.RegularExpressions.Match]’ to type ‘System.IConvertible’.
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)
— End of inner ExceptionDetail stack trace —
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataTable.NewRecordFromArray(Object value)
at System.Data.DataRowCollection.Add(Object values)
at UiPath.Core.Activities.AddDataRow.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)
@harishk5 Matches itself is a collection of all matches (IEnumerable<Match>) in the text you pass. You need to iterate through the matches result that you get. And to get the actual value, you should use Match.Value
Thank you KannanSuresh. I am using foreach to iterate through the collection and then when i try to save it to a data table via ‘Add Data Row’ activity, i get this error. Please find the screenshot below.
I used {item.toString} as the arrayrow and again getting error message as below.
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ArgumentException: Input string was not in a correct format.Couldn’t store bindu.pustakala@evry.com in Email Ids Column. Expected type is Int32. ----> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)
— End of inner ExceptionDetail stack trace —
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataTable.NewRecordFromArray(Object value)
at System.Data.DataRowCollection.Add(Object values)
at UiPath.Core.Activities.AddDataRow.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)
"An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.ArgumentException: Input string was not in a correct format.Couldn’t store bindu.pustakala@evry.com in Email Ids Column."
Buddy, i am also confused. I didnt create column name as ‘Email Ids’ in the data table. When i try to rename the column name from emailaddress to ‘Email Ids’, i get this error below. How do i find this Email Ids column and where can i change its type.
Source: Add Data Column
Message: A column named ‘Email Ids’ already belongs to this DataTable.
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Data.DuplicateNameException: A column named ‘Email Ids’ already belongs to this DataTable.
at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column)
at System.Data.DataColumnCollection.BaseAdd(DataColumn column)
at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column)
at UiPath.Core.Activities.AddDataColumn`1.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)
Yup. Got it, i totally forgot to change the column configuration inside the datatable. I changed from Int32 to String and it worked. Thanks Palaniyappan and KannanSuresh.