MIN MAX for GREP?

Discussion in 'Perl Misc' started by Chris Doe, Nov 20, 2003.

  1. Chris Doe

    Chris Doe Guest

    I have a large .CSV file with 10 fields on each line. The first field
    is a EPOCH date which is the only field I am interested in.

    My dilemma: Based on a START and END date provided from the user, I
    need to be able to PIPE all lines within that CSV file to a temporary
    file which start with an EPOCH date ( >= START date and <=END date )

    I have been trying something along the lines of

    grep "^\{$min, $max\}" file.csv > temp.csv but no luck... Any ideas

    Regards
    Chris
    Chris Doe, Nov 20, 2003
    #1
    1. Advertising

  2. Chris Doe <> wrote:

    > Subject: MIN MAX for GREP?



    There is no need to shout at us.


    > I have a large .CSV file with 10 fields on each line. The first field
    > is a EPOCH date which is the only field I am interested in.
    >
    > My dilemma: Based on a START and END date provided from the user, I
    > need to be able to PIPE all lines within that CSV file to a temporary
    > file



    That cannot be done.

    A pipe connects two _programs_.

    You simply want to _write_ it to a file, I expect.


    > which start with an EPOCH date ( >= START date and <=END date )
    >
    > I have been trying something along the lines of
    >
    > grep "^\{$min, $max\}" file.csv > temp.csv but no luck... Any ideas



    That is not Perl, that is grep(1).

    Please ask Perl questions in the Perl newsgroup, ask questions about
    OS-specific tools in the appropriate OS-specific newsgroup.


    Here is how you can do it with Perl:

    # untested
    while ( <CSV> ) {
    # get fields into @record somehow (hint: use a module)
    print OUT if $record[0] >= $start and $record[0] <= $end;
    }


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Nov 20, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick

    Max Min

    Patrick, Jul 29, 2004, in forum: VHDL
    Replies:
    1
    Views:
    3,017
    Jonathan Bromley
    Jul 29, 2004
  2. Lois
    Replies:
    1
    Views:
    3,215
    Ryan Stewart
    Dec 27, 2004
  3. juergen
    Replies:
    3
    Views:
    565
    opalinski from opalpaweb
    Sep 20, 2006
  4. Albert Hopkins

    When is min(a, b) != min(b, a)?

    Albert Hopkins, Jan 21, 2008, in forum: Python
    Replies:
    31
    Views:
    824
    Albert van der Horst
    Feb 4, 2008
  5. carmen

    Converting hrs and min to just min

    carmen, Aug 10, 2004, in forum: ASP General
    Replies:
    4
    Views:
    129
    carmen
    Aug 10, 2004
Loading...

Share This Page