LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash or Perl Script - recursive search. (https://www.linuxquestions.org/questions/linux-newbie-8/bash-or-perl-script-recursive-search-906660/)

vinnat 10-05-2011 07:18 PM

Bash or Perl Script - recursive search.
 
I need the help of this forum.
I have a text table which has only two fields: “Student Name” and “Test approved”. This table lists all the students that have approved different tests, but only 3 tests are mandatory (necessary) to be promoted, which are: “test_1” ; “ test_2” and “ test_3” .
The remaining tests (like “test_4”; “test_5”, etc.) are optional, because they are not necessary for a student to be promoted.

I need a script (Bash or Perl, etc. or Excel or Access) to accomplish the task of adding to the table a third field “Final Result”, having the result of the recursive search that has to be done.

This field, “Final Result”, can only have one of the following possible results:

• “Promoted” : only if test_1 AND test_2 AND test_3 were approved.
• “Not_Promoted_Fail Test_1” : because has failed test_1, even if has approved other mandatory tests or optional tests.
• “Not_Promoted_Fail Test_2” : because has failed test_2, even if has approved test_1 and test_3, or other optional tests.
• “Not_Promoted_Fail Test_3” : because has failed test_3”, even if has approved test_1 and test_2.

This is the final result (a new text table with 3 fields) which I need:

"Student Name" "Test approved" "Final Result"
Peter Test_1 Promoted
Peter Test_5 Promoted
Peter Test_3 Promoted
Peter Test_2 Promoted
John Test_3 Promoted
John Test_2 Promoted
John Test_1 Promoted
John Test_6 Promoted
Mary Test_4 Not_Promoted_Fail Test_2
Mary Test_1 Not_Promoted_Fail Test_2
Mary Test_3 Not_Promoted_Fail Test_2
Mary Test_7 Not_Promoted_Fail Test_2
Mary Test_5 Not_Promoted_Fail Test_2
Mary Test_6 Not_Promoted_Fail Test_2
Robert Test_2 Not_Promoted_Fail Test_1
Robert Test_3 Not_Promoted_Fail Test_1
Jane Test_1 Not_Promoted_Fail Test_3
Jane Test_2 Not_Promoted_Fail Test_3
Jane Test_7 Not_Promoted_Fail Test_3

Many thanks to all of you!

Vincenzo Natale (Argentina)
vinnat@speedy.com.ar

TB0ne 10-06-2011 08:51 AM

Quote:

Originally Posted by vinnat (Post 4491144)
I need the help of this forum.
I have a text table which has only two fields: “Student Name” and “Test approved”. This table lists all the students that have approved different tests, but only 3 tests are mandatory (necessary) to be promoted, which are: “test_1” ; “ test_2” and “ test_3” .
The remaining tests (like “test_4”; “test_5”, etc.) are optional, because they are not necessary for a student to be promoted.

I need a script (Bash or Perl, etc. or Excel or Access) to accomplish the task of adding to the table a third field “Final Result”, having the result of the recursive search that has to be done.

This field, “Final Result”, can only have one of the following possible results:

• “Promoted” : only if test_1 AND test_2 AND test_3 were approved.
• “Not_Promoted_Fail Test_1” : because has failed test_1, even if has approved other mandatory tests or optional tests.
• “Not_Promoted_Fail Test_2” : because has failed test_2, even if has approved test_1 and test_3, or other optional tests.
• “Not_Promoted_Fail Test_3” : because has failed test_3”, even if has approved test_1 and test_2.

This is the final result (a new text table with 3 fields) which I need:

"Student Name" "Test approved" "Final Result"
Peter Test_1 Promoted

We will certainly be glad to HELP you. Post what you've written so far, and where you're stuck, along with a sample of the input data, and we can assist. However, we are NOT going to write your scripts for you....we will be very happy to work with you to get things going, but you will have to put effort into this on your own.

I suggest you check out the bash scripting guide, if you need help getting started. Covers opening files, reading them, and writing tests.
http://tldp.org/LDP/abs/html/

If you would like someone to write programs for you, feel free to post this job listing in the LQ Job Marketplace, with how much you're willing to pay.


All times are GMT -5. The time now is 05:12 PM.