LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2011, 07:24 AM   #1
vinnat
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
Smile Searching a table and adding a new field, using a Bash or Perl Script


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) 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

Last edited by vinnat; 10-04-2011 at 03:28 PM. Reason: Correction.
 
Old 10-03-2011, 08:32 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
Sounds like a great plan What have you done in preparation to solve it? (apart from ask here of course)
 
Old 10-03-2011, 08:46 AM   #3
vinnat
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
I tried with Excel, Access, OpenOffice, but I failed.
Then, started to read bash commands and scripts, but I do not know how to do the recursive search or loop. Thanks for reading the post.
 
Old 10-03-2011, 02:32 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
See if this page can give some insight :- http://tldp.org/LDP/abs/html/loops.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help for simple bash script - searching strings lpallard Linux - Software 21 10-09-2011 09:01 PM
[SOLVED] bash script is reprinting part of a field from an awk statement ?? SharpyWarpy Linux - General 13 04-22-2010 04:58 AM
Searching tips for bash script hardening norbert74 Linux - Security 6 02-09-2010 01:26 PM
bash script to sort data by field lothario Linux - Newbie 4 08-26-2009 03:23 AM
bash script for database searching using crontab saurya_s Linux - Software 5 01-22-2004 09:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration