Results 1 to 16 of 16

Thread: Filter Lines of Text File based on Value AND Date

Threaded View

  1. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,434

    Re: Filter Lines of Text File based on Value AND Date

    Try this. Tested now...

    Code:
    Dim lines() As String = IO.File.ReadAllLines(path)
    Dim distinctBadges() As String = lines.Select(Function(l) l.Substring(0, 13)).Distinct.ToArray
    
    Dim lastLines As New List(Of String)
    For Each db As String In distinctBadges
        For x As Integer = 0 To lines.GetUpperBound(0) - 1
            If lines(x).StartsWith(db) And Not lines(x + 1).StartsWith(db) Then
                lastLines.Add(lines(x))
            End If
        Next
    Next
    This is assuming you want the last entry for every distinct badge. Using your text file, i found 12 lines...
    Last edited by .paul.; Oct 24th, 2021 at 04:00 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width