Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

What does happen when you get two identical dates?

As you don't say anything about the context, supposing unix-like, I thought I could mention various one-liners to get a feeling of your data:

  • UN*X golf. It is always worth playing with your system sort as it is often optimized for speed.
  • a Minimal Perl approach.
  • % steph@apexPDell2 (/home/stephan/t) % % cat data.txt # I added the last line + item group entry_date 34 gr1 2003-03-02 12 gr1 1990-03-14 39 gr3 2002-04-11 66 gr4 2006-03-16 32 gr3 1998-02-13 90 gr1 2004-06-15 55 gr4 1999-06-15 10 gr1 2003-03-02 % steph@apexPDell2 (/home/stephan/t) % % LC_ALL=C sort -k 3 data.txt | perl -lna -e 'print if $F[1] eq q{gr1} + and $F[0] == 34' 34 gr1 2003-03-02 % steph@apexPDell2 (/home/stephan/t) % % sort -k 3 data.txt | grep gr1 | sort -n | head -n1 10 gr1 2003-03-02

    The last one reads as sort on the date, select group gr1, select on the first numerically and keep tghe first line. In this particular case it is faster to grep first.

    cheers --stephan

    In reply to Re: Pulling out oldest entries from a text file by sgt
    in thread Pulling out oldest entries from a text file by Angharad

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others exploiting the Monastery: (8)
    As of 2024-04-23 10:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found