Question about DataTable row filtering

Hello, there,

I used a “Read CSV” to read a csv file, which contains a column of “Club Member” with values of “Yes” or “No”. Then I tried to filter (Assign activity) this csv file with:
names.Select("[Club Member]= ‘Yes’ ")**
I hope a DataTable with rows of “Club Member” = “Yes” will be created.

However, I got below exception: Cannot find column [‘Yes’].

“Yes” is a value of that column. How is ‘Yes’ treated as a column ?

Thanks

19.9.2+Branch.master.Sha.0928919eb1def274fdabeb0849d03a125c50fe6a

Source: Assign

Message: Cannot find column [‘Yes’].

Exception Type: System.Data.EvaluateException

RemoteException wrapping System.Data.EvaluateException: Cannot find column [‘Yes’].
at System.Data.NameNode.Bind(DataTable table, List1 list) at System.Data.BinaryNode.Bind(DataTable table, List1 list)
at System.Data.DataExpression.Bind(DataTable table)
at System.Data.DataExpression…ctor(DataTable table, String expression, Type type)
at System.Data.DataTable.Select(String filterExpression)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hi @dkang

is addheaders property been checked for read csv activity

Thanks
ashwin S

I could not find “Add Headers” property. Here is the screen shot of Read CSV

Hi @dkang
Are you Able to select the column

like Datatable.Select("[Club Member]= ‘Yes’ ").CopyToDatatable()

Thanks

ashwin S

The .CopyToDatatable() gave a compilation error:
cannot convert to 1-dimentional array.

Without CopyToDatatable(), it passed the compiling

Hi @dkang
what type is club members

Thanks
ashwin S

image

the type is String

hi @dkang
dont give club members type As string give it as Datatable type

Thanks
ashwin S

Here is the debugging messages, it seems the csv file was loaded correctly. But the select statement does nor work.

[First,Last,Club Member
Jay,Gavin,Yes
Zachary,Craig,No
Sherry,Hooks,Yes
Marcella,Knipp,Yes
Melvin,White,No
Nancy,Fox,Yes
Kristina,Turner,No
Craig,Saucier,No
Raymond,Wilson,No
Kent,Danley,No
]

the type of clubMembers is DataRow

@AshwinS2 thanks for your patient for helping

There’s a builtin UiPath activity for this, Filter DataTable.

Here’s an example of how it should be used given your situation: Test_ReadCSVAndFilter.xaml (6.5 KB)

here you go with the xaml using SELECT method
select.zip (2.3 KB)

Cheers @dkang