how to split the file into two sections....

Discussion in 'Python' started by indu_shreenath@yahoo.co.in, Dec 4, 2012.

  1. Guest

    Hi:
    I have a text as
    version comp X - aa
    version comp Y - bbb
    version comp Z -cc

    12.12 Check for option 1

    12:13 Pass Test 1
    12:14 verified bla bla bla
    12.15 completed

    12.16 Fail Test 2
    12:17 verified bla bla bla
    12.18 completed

    12.19 Fail Test 3
    12:20 verified bla bla bla
    12.21 completed

    12.22 Check for option B

    12:23 Pass Test4
    12:24 verified bla bla bla
    12.25 completed

    12.26 Fail Test 5
    12:27 verified bla bla bla
    12.28 completed

    12.29 Fail Test 6
    12:30 verified bla bla bla
    12.31 completed

    In this I want to split the file to two sections to post the summary as

    Check for option 1
    Pass 2
    Fail 1
    Check for option 2
    Pass 2
    Fail 1
    , Dec 4, 2012
    #1
    1. Advertising

  2. Peter Otten Guest

    wrote:

    > Hi:
    > I have a text as
    > version comp X - aa
    > version comp Y - bbb
    > version comp Z -cc
    >
    > 12.12 Check for option 1
    >
    > 12:13 Pass Test 1
    > 12:14 verified bla bla bla
    > 12.15 completed
    >
    > 12.16 Fail Test 2
    > 12:17 verified bla bla bla
    > 12.18 completed
    >
    > 12.19 Fail Test 3
    > 12:20 verified bla bla bla
    > 12.21 completed
    >
    > 12.22 Check for option B
    >
    > 12:23 Pass Test4
    > 12:24 verified bla bla bla
    > 12.25 completed
    >
    > 12.26 Fail Test 5
    > 12:27 verified bla bla bla
    > 12.28 completed
    >
    > 12.29 Fail Test 6
    > 12:30 verified bla bla bla
    > 12.31 completed
    >
    > In this I want to split the file to two sections to post the summary as
    >
    > Check for option 1
    > Pass 2
    > Fail 1
    > Check for option 2
    > Pass 2
    > Fail 1


    Open the file
    Iterate over the lines
    Extract the second word
    If it's "Check" print the current stats (if any) and remember the
    line
    If it's "Fail" increase a fail counter
    If it's "Pass" increase a fail counter
    Print the current stats (if any)

    [Optional] Come back here for help with the details once you have some code.
    Peter Otten, Dec 4, 2012
    #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. Raman
    Replies:
    6
    Views:
    4,679
    santosh
    Aug 3, 2007
  2. Roy Smith
    Replies:
    1
    Views:
    32
    Steven D'Aprano
    Apr 25, 2014
  3. Chris Angelico
    Replies:
    0
    Views:
    36
    Chris Angelico
    Apr 25, 2014
  4. Tim Chase
    Replies:
    0
    Views:
    42
    Tim Chase
    Apr 25, 2014
  5. Jussi Piitulainen

    Re: how to split this kind of text into sections

    Jussi Piitulainen, Apr 25, 2014, in forum: Python
    Replies:
    0
    Views:
    30
    Jussi Piitulainen
    Apr 25, 2014
Loading...

Share This Page