ianhyj
(Ian Hu)
June 12, 2020, 12:47pm
1
Hi all,
As the subject suggests, if I have a datatable(dT) with 4000 rows x 25 columns and I need replace any null value to 0, but checking cell by cell is going to take more than 30 mins.
Is there any faster and more efficient way to do it?
Thanks!
Any luck? I am also looking for a similar workaround in the data table?
ppr
(Peter Preuss)
September 14, 2020, 12:52pm
3
Find some starter help here:
Replace_AllCellsAllRows_EmptyNothingWith0.xaml (7.3 KB)
feel free to adopt it to your specific scenario
2 Likes
Hi @ianhyj
You can refer the below link for more:
@Rachel7
this is maybe a too quick shot as it replace any space in any column to NA and returns a datatable.
But you can give a try
(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()
NEW VERSION, simplified:
(From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) x.ToString.Trim.Replace(" ","NA")).toArray()
Select dtCorrected.Rows.…
This was solved by @ppr too!
1 Like