FAQ
hi..
im parsing the text file containing the details of the testcases
failed.From the file i wanted to obtain only the testcase names and
enter them in the excel sheet.

the pattern of the text file is:

FILE : NW_PTH_TFG6_SCEN_4_2_FIFO.c, LINE : 240 TEST FAIL to get entire:
32768 bytes
NW_PTH_TFG6_SCEN_4_2_FIFO.c 340 DATA NOT MATCHING, TEST FAIL
TEST FAIL SYSCALL_TEST_SCEN_4_1_ALL.c at line 355
FILE:US_TFG7_SCEN_4_1.c,LINE:189, Server side TEST FAIL
FAIL BREW_SCEN_4_1.c 219: can't mount
FAIL BREW_SCEN_4_1.c 121: can't umount
<< BREW_SCEN_4_1.c TEST FAIL errno:No such file or directory >>
<< BREW_SCEN_4_1.c TEST FAIL >> error:Invalid argument

i used the ' re module' and its function partition,but im facing
problem in obtaining only the testcase names..
if anyone know the answer please help me..
Thanks for ur help.

Search Discussions

  • Terry Reedy at Apr 15, 2010 at 4:05 pm

    On 4/15/2010 2:57 AM, chaaana wrote:
    hi..
    im parsing the text file containing the details of the testcases
    failed.From the file i wanted to obtain only the testcase names and
    enter them in the excel sheet.

    the pattern of the text file is:

    FILE : NW_PTH_TFG6_SCEN_4_2_FIFO.c, LINE : 240 TEST FAIL to get entire:
    32768 bytes
    NW_PTH_TFG6_SCEN_4_2_FIFO.c 340 DATA NOT MATCHING, TEST FAIL
    TEST FAIL SYSCALL_TEST_SCEN_4_1_ALL.c at line 355
    FILE:US_TFG7_SCEN_4_1.c,LINE:189, Server side TEST FAIL
    FAIL BREW_SCEN_4_1.c 219: can't mount
    FAIL BREW_SCEN_4_1.c 121: can't umount
    << BREW_SCEN_4_1.c TEST FAIL errno:No such file or directory>>
    << BREW_SCEN_4_1.c TEST FAIL>> error:Invalid argument
    I do not see any consistent pattern in the above lines.
    What output do you see from filtering them?
    i used the ' re module' and its function partition,but im facing
    problem in obtaining only the testcase names..
    If I could not write a satisfactory re, I would be tempted to write
    explicit code to process the lines, possibly defining appropriate search
    states.

    Terry Jan Reedy
  • Tim Chase at Apr 15, 2010 at 6:39 pm

    On 04/15/2010 11:05 AM, Terry Reedy wrote:
    On 4/15/2010 2:57 AM, chaaana wrote:
    hi..
    im parsing the text file containing the details of the testcases
    failed.From the file i wanted to obtain only the testcase names and
    enter them in the excel sheet.

    the pattern of the text file is:

    FILE : NW_PTH_TFG6_SCEN_4_2_FIFO.c, LINE : 240 TEST FAIL to get entire:
    32768 bytes
    NW_PTH_TFG6_SCEN_4_2_FIFO.c 340 DATA NOT MATCHING, TEST FAIL
    TEST FAIL SYSCALL_TEST_SCEN_4_1_ALL.c at line 355
    FILE:US_TFG7_SCEN_4_1.c,LINE:189, Server side TEST FAIL
    FAIL BREW_SCEN_4_1.c 219: can't mount
    FAIL BREW_SCEN_4_1.c 121: can't umount
    << BREW_SCEN_4_1.c TEST FAIL errno:No such file or directory>>
    << BREW_SCEN_4_1.c TEST FAIL>> error:Invalid argument
    I do not see any consistent pattern in the above lines.
    What output do you see from filtering them?
    My guess is that it's the "FILE:...LINE:..." line(s) that the OP
    is interested in, in which case one could do something like

    r = re.compile(r'^FILE\s*:\s*(.*?),\s*LINE\s*:\s*(\d+)')
    for line in file('input.txt'):
    m = r.match(line)
    if m:
    print m.group(1), m.group(2)

    Alternatively, if you're in the regexp-avoiding camp, you might
    be able to get away with

    LINE_BIT = ', LINE : '
    for line in file('input.txt'):
    if line.startswith('FILE :') and LINE_BIT in line:
    leader, _ = line.split(LINE_BIT, 1)
    _, fname = leader.split(":", 1)
    fname = fname.strip()
    print repr(fname)

    but that relies on the LINE_BIT remaining constant (the
    "LINE:189" doesn't have spaces where the first "LINE : 240" does
    have extra spaces; and the same with the extra spaces around the
    "FILE" portion).

    -tkc

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 15, '10 at 6:57a
activeApr 15, '10 at 6:39p
posts3
users3
websitepython.org

3 users in discussion

Tim Chase: 1 post Terry Reedy: 1 post Chaaana: 1 post

People

Translate

site design / logo © 2023 Grokbase