Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data extraction from file

Status
Not open for further replies.

deepa20

Programmer
Sep 19, 2006
12
DE
Hello ,

I have 2 files, First file (master.txt) contains 2 coulnms,
first coulumn is Test case name and other is product name.

Second file contains only one column test case name and fail record contains ! mark infornt for the record.

I want to add product name in second file comparing test case name .

If Second.testname= first.testcasename
add Product name in second file infront of test case name .




 
I have 2 files , one is master file and another file i am genearting which contains Number of fails for all host & version.

The first file is master file which contains 2 column, Test Case name and Product Name:
daily/DB/attach/attach_redundancy.exp: YRS
daily/DB/help/help.exp: SiCat
daily/DB/hole_fail_rate/hfr-circular.exp: APPS
daily/DB/markerfile/narrow_space_wide_neighbor.ex YRS

The Second File : Fails.log data are like below , the ! is infront of fail record .
/users/testsuite/db/SiCat/2006-09-04/10/kracherl/run.log
! daily/DB/attach/attach_redundancy.exp:
! daily/DB/help/help.exp:
! daily/DB/hole_fail_rate/hfr-circular.exp:
! daily/DB/markerfile/narrow_space_wide_neighbor.exp:
! daily/DB/markerfile/npt.exp:
/users/testsuite/db/SiCat/2006-09-04/10_64/limo/run.log
! daily/DB/measure_stack/ms_objects_transistor.exp:
! daily/DB/network/transistor_exact_active.exp:
! daily/DB/output/error1.exp:
/users/testsuite/db/SiCat/2006-09-04/devel_64/limo/run.log
! daily/DB/hole_fail_rate/hfr-circular.exp:
! daily/DB/markerfile/cws.exp:
! daily/DB/markerfile/narrow_space_wide_neighbor.exp:

Now i want to generate the report like0
Ver Host Total YRS SiCat APPS PSD NO
10 kracherl 34 23 1 2 6 2
10_fast via2 30 18 1 2 7 2
9 optimator 36 29 1 2 4 0
 
I have not fully understood what do you want to do here.

To able to acheive what you have written in your first post, you can try like following:
Take data in first file ( having two columns ) and form a variable.
Go through the second file i.e.loop ( having only one column line by line ). Use regex for the current line with the variable form above and build a string.
After the loop ends, write the formatted string in second file.



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Where are you expecting to get the version number from? It doesn't seem to appear in either file...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Yeah i want to write the code like this and generate the report . I am very new in Unix and Perl programming .

Please send me the peace of perl code for this
thanks in advance
 
the line which doesnt contain ! sign has version & host no after date ..

onemoreting the product name are fixed
 
You just want someone to write all the code for you? Maybe someone will, but this is not a script writing service.
 
I know this is not a scrpit writing server, but i have to write this code on urgent base , i am generating report manually and i am also trying to write the code

It will be great help if someone will help me .

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top