I am parsing a text file and storing the results in an ArrayList. Prior to appending the data I need to compare the string in the current and next index looking for duplicate/unwanted data.
Here is what the data in the ArrayList looks like;
Alice Smith;34578;01/01/2010;10:10:00 PM;;Add Punch
Alice Smith;34578;01/01/2010;10:10:00 PM;;Delete Punch
Brian Smith;35678;01/02/2010;7:30:00 AM;;Add Punch
Brian Williams;37978;01/02/2010;7:30:00 AM;;Edit Punch
Brian Williams;37978;01/02/2010;7:30:00 AM;;Delete Punch
I need to add the following logic to my code prior to appending the data from the array.
For Each i as String in MyArrayList
If Not lines(i).Contains("Add Punch") & _
Not lines(i+1).Contains("Delete Punch") then
If Not lines(i).Substring(everything left of the 5th ";") =
lines(i+1).Substring(everything left of the 5th ";") then
System.IO.File.AppendAllText("D:\ParsedFile.txt", s & Environment.NewLine)
i=i+1 'skip to the third index
next
Simply put I need to ignore the two strings for Alice because a time card punch was added and then deleted for the same person and for the same time period. Can this be done while the data is still in the arraylist?
Thanks in advance for the help,
Bud
Here is what the data in the ArrayList looks like;
Alice Smith;34578;01/01/2010;10:10:00 PM;;Add Punch
Alice Smith;34578;01/01/2010;10:10:00 PM;;Delete Punch
Brian Smith;35678;01/02/2010;7:30:00 AM;;Add Punch
Brian Williams;37978;01/02/2010;7:30:00 AM;;Edit Punch
Brian Williams;37978;01/02/2010;7:30:00 AM;;Delete Punch
I need to add the following logic to my code prior to appending the data from the array.
For Each i as String in MyArrayList
If Not lines(i).Contains("Add Punch") & _
Not lines(i+1).Contains("Delete Punch") then
If Not lines(i).Substring(everything left of the 5th ";") =
lines(i+1).Substring(everything left of the 5th ";") then
System.IO.File.AppendAllText("D:\ParsedFile.txt", s & Environment.NewLine)
i=i+1 'skip to the third index
next
Simply put I need to ignore the two strings for Alice because a time card punch was added and then deleted for the same person and for the same time period. Can this be done while the data is still in the arraylist?
Thanks in advance for the help,
Bud