One of them is “Modified Date” and it has this format “dd.MM.yyyy HH:mm” ==> for example 01.01.2010 23:00"
This date I change from string to date and give it the format like this: dd.MM.yyyy
For now I have a complicated loop where I transform each item into date and then compare it with another date (not from this file, so the comparedTo date is static) ==> e.g. 01.01.2020 > 02.01.2020
This is very expensive and takes veeeeery long (the csv has over 5000 lines).
Now I wanted to basically ask if theres a better method for this with a simple filter or something. I found that there is a filter activity but that doesn’t give me the possibility to change the format of the current row’s date string, since my comparedTo date is in this format dd.MM.yyyy / where as the currentRow date has this format dd.MM.yyyy mm.HH(or at least I haven’t figured it out).
How can I make this much more performant without going the UI route (UI would be simple since I just open Excel and set a date filter on this column). But I would like to avoid going the UI Route if that makes sense.
After reading you CSV data into a data table using Read CSV activity, for example- dtTest, You can assign the below LINQ query to a new data table for example -dtFilteredTable
(From d In dtTest.AsEnumerable Where dateTime.ParseExact(d(0).toString,“dd.MM.yyyy HH.mm”, System.Globalization.CultureInfo.InvariantCulture).Date < DateTime.Parse(strDateToCompare) Select d).CopyToDataTable
Here, strDateToCompare is the static date variable stored as a text (you can directly pass the date variable as well if you already have in a proper date variable) and the d(0) indicates the 1st column where my dates are coming in CSV. You can change the index value as per your requirement.
NOTE: Also, ensure in order to use LINQ queries the assembly reference: System.Data.DataSetExtensions must be added to your xaml file.
this is so fast wow. But unfortanetely the new datatable it builds has the same row length as the one it copies it. So the boolean check doesn’t work. It still has 5000 entries but it should have just a few when the date is set to for example: 18.10.2021 (comparedTo)