Filter a large amount of data and datatable manipulation

Hello All,
I have a big csv file that containq some infos with a column that has dates
So i need to filter this column of dates with the following conditions
If column date exceeds two months from now i need to add a column to the table with value “type 1”
If column date exceeds 3 months from now i need to add a column with value “type 2”.

I believe that i can do it with for each and if condition but when the file size is big it’ll take a lot of time so i need an optimized solution , any ideas please ??

Kind Regards

Hi,

How about the following using invokeCode and LINQ?

dt.AsEnumerable.ToList().ForEach(Sub(r) 
If (CDate(r("date"))>Today.AddMonths(2)) Then
	If  (CDate(r("date"))>Today.AddMonths(3)) Then
        r("type")="type2"		
    Else
	        r("type")="type1"	
    End If
End If
End Sub
)

Sample20230922-1L.zip (2.8 KB)

If it doesn’t work due to your date format, can you share your input and expected output as file? It’s no problem if dummy data.

Regards,

Hello Yoichi,

Thanks for your prompt reply , here is an exp of input file that need to be filtered and the output must be a data table with all the column of input file plus the column “type”…

inputFile.xlsx (17.0 KB)

Kind Regards,

Hi,

Your input file is CSV isn’t it? How about the following?

Sample20230922-1L (2).zip (3.2 KB)

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.