Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8950789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:30:57+00:00 2026-06-15T13:30:57+00:00

UPDATE I have got a log file of 1000 lines containing some reference. Time

  • 0

UPDATE

I have got a log file of 1000 lines containing some reference.

Time Reference Date of start Date of end
12:00 AT001 13 November 2011 15 November 2011
13:00 AT038 15 December 2012 17 December 2012
14:00 AT076 17 January 2013 19 January 2013

$ref1 = AT038

Basically, I want to parse the log file and have an output (line by line) for $ref1 such as :

Time : 13h
Reference : AT038
Date of start : 15 December 2012
Date of end : 17 December 2012

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:30:58+00:00Added an answer on June 15, 2026 at 1:30 pm

    try:

    $ref1 = "AT038"
    $csv = Import-Csv .\myfile.txt -Delimiter ' '#Import file as CSV with space as delimiter
    $csv | ? { $_.reference -EQ $ref1 } | FL #Piping each line of CSV to where-object cmdlet,  filtering only line where value of column reference is equal to $ref1 variable value. Piping the result of the filtering to file-list to have output as requested in OP.
    

    Code added after requisite are changed in OP:

    $ref1 = "AT038"
    $txt = gc .\myfile.txt
    $txt2 = $txt | % { $b = $_ -split ' '; "$($b[0]) $($b[1]) $($b[2])_$($b[3])_$($b[4]) $($b[5])_$($b[6])_$($b[7])" }
    $csv = convertfrom-csv -InputObject $txt2 -Delimiter ' ' 
    $csv | ? { $_.reference -EQ $ref1 } | FL 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE - I have fixed some mistakes in the code below and the images
I have to update different server data which takes huge time. I have to
I have some Javascript code that is basically an elapsed timer for a file
I have asked this question some time ago to get an idea of speeding
I have an incoming lazy stream lines from a file I'm reading with tail-seq
Update I have just tried Pinning my site to the Taskbar again (after removing
UPDATE I have updated my code in response to @MichaelRushton comments. I am now
UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
I have update panel that content check box, textbox, 3 DropDownList with CascadingDropDown extender.
I have scenario, I have two update panels on the page (both have update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.