Dev2
(Dev2)
November 18, 2020, 10:50am
1
Hi Everyone,
I have table in excel with 3 columns some of cell is empty how I can replace empty cell with 0 using LINQ .
I have read this topic but I got error can any one guide me to do this .
Thanks
ppr
(Peter Preuss)
November 18, 2020, 11:11am
3
@Dev2
can you please share more details to the error that you have got. What was done so far?
Dev2
(Dev2)
November 18, 2020, 11:18am
4
@ppr
I have dateable , and I put assign with this code
(From r In dtData.AsEnumerable
Select ia = r.ItemArray.toList
Select ic = ia.ConvertAll(Function (e) e.ToString.Trim.Replace(" ",“NA”)).toArray()
Select dtCorrected.Rows.Add(ic)).CopyToDataTable()
it is correct ?
Dev2
(Dev2)
November 18, 2020, 11:25am
5
@ppr
Compiler error(s) encountered processing expression “(From r In dtData.AsEnumerable Select ia = r.ItemArray.toList Select ic = ia.ConvertAll(Function (e) e.ToString.Trim.Replace(” “,“NA”)).toArray()Select dtCorrected.Rows.Add(ic)).CopyToDataTable()”.
‘Rows’ is not a member of ‘UiPath.Core.GenericValue’. Sequence.xaml
This the error
ppr
(Peter Preuss)
November 18, 2020, 11:34am
6
@Dev2
find some starter help here:
Replace_AllCellsAllRows_EmptyNothingWith0.xaml (7.3 KB)
ensure the correct datatypes. The issue from above comes from the wrong datatype; generic value. dtCorrected has to be of datatype Datatable
3 Likes
Dev2
(Dev2)
November 18, 2020, 11:54am
8
it could be dynamic so if we have any number of coalman’s and rows ?
ppr
(Peter Preuss)
November 18, 2020, 11:57am
9
Yes, it is dynamic and look in every column and every row for it
ppr
(Peter Preuss)
November 18, 2020, 12:09pm
11
@Dev2
the syntax: dtData.Rows(2)(0) means: third row from datatable first column
Dev2
(Dev2)
November 18, 2020, 12:12pm
12
yes that what I mean , it is possible if we do not specify the row ? as dynamic
ppr
(Peter Preuss)
November 18, 2020, 12:15pm
13
didn’t get you. What is needed, what is the requirement?
Dev2
(Dev2)
November 18, 2020, 12:18pm
14
I wrote 3 Colmans only for example, so Mabey the coulman number change now I have 3 coulman but Mabey we have more… are you geating me?
ppr
(Peter Preuss)
November 18, 2020, 12:26pm
15
as the statement runs dynamicly over all rows and columns it is already fully dynamic.
in case of all columns for a particular row are to handle then give a try
Assign activity:
left side: datarowVarCorrected (DataType: Datarow)
right side
dtData.Rows(2).ItemArray.Select(Function (e) If(isNothing(e) OrElse String.IsNullOrEmpty(e.toString), 0, e)).toArray
1 Like
Dev2
(Dev2)
November 18, 2020, 9:08pm
17
ppr:
(
@ppr
sorry it is not work with me , i have write range to get result but it is not give me the correct output .
ppr
(Peter Preuss)
November 18, 2020, 9:20pm
18
@Dev2
please share as much details with us, so we have a chance to know what was done and what it is the issue. Thanks
Dev2
(Dev2)
November 18, 2020, 9:24pm
19
Okay , for example I have
co1- col2 - col3
3 6
4 8
5 8
So I have this value but some of the cell empty how I can write 0 in the empty cell
ppr
(Peter Preuss)
November 18, 2020, 9:25pm
20
what is implemented so far? Can you share XAML or some screenshots along with details?
Data comes from excel?
Thanks