I have a file of test results it is formatted as follows:

        School |fname| lname | sub| testnum|score| grade|level
MLK School | John | Smith | RE | Test 1| 95| A | Prof
MLK School | John | Smith | RE | Test 2| 97| A | Prof
MLK School | John | Smith | RE | Test 3| 93| A | Prof
MLK School | John | Smith | RE | Test 4| 89| B | NP

What I would like to come out with is as follows:

                SCHOOL                          |fname| lname | sub|
testnum|score| grade|level
MLK School |John|Smith|RE|Test 1| 95| A | Prof| Test 2| 97|A|Prof|
Test 3|93|A|Prof|Test4|89|B|NP

I have started but can not figure out how to get this resulting file.
Here is what I have so far:


$file_to_read ="E:/My Documents/KNOWS/Second Run at Knows/
KNOWS_All_Student_Benchmark_Results_Improved_2011091402.csv";
$file_to_write ="E:/My Documents/KNOWS/Second Run at Knows/
KNOWS_All_Student_Benchmark_Results_One_File_2011091402.csv";

open( file1, $file_to_read) || die ("could not open file1");

open( file2, '>>',$file_to_write);

while($line= <file1>) {

chomp $line;

(
$schoolname,
$studentkey,
$sfirstname,
$slastname,
$subject_code,
$testkey,
$test_grade,
$test_score,
$test_level
)=split /\|/, $line;

if length($studentkey gt 0) {
    while ($line2 = <file>) {

        chomp $line2;
        (
            $studentkey_file2,
            $testkey_file2,
            $rest_file2
        ) = split/\|/, $line2;

        if ($studentkey_file2 gt 0 && $studentkey eq
$studentkey_file2) {

        }



    }
    #second while statement end
}
}
    #first while statement end

-Studentkey is the information I want to match on but can not figure
out what direction to go.

Can someone please help steer me in the right direction?

Thanks in advance.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to