Here is another way using Perl...
Assuming you have a file "pay1" containing:
EmployeeID
101
Day_type, day
vacation,1/2/2009
sick day, 3/2/2009
personal day, 4/5/2009
jury duty day, 5/5/2009
Here is a perl program "pay1.pl"...
#!/usr/bin/perl -w
while (<>) { #while not end of standard input
chomp; #Take of end of line char
$line = $_; #whole line string wo/end of line char
@a = split (/,/, $line); #Split line by comma into array
if ($. == 1) { #only on line 1
$col1_title = $a[0]; #Grab text EmployeeID
}
elsif ($. == 2) { #only on line 2
$col1_value = $a[0]; #Grab 101
}
elsif ($. == 3) { #only on line 3
$col2_title = $a[0]; #Grab Day_type
$col3_title = $a[1]; #Grab day
#print heading line
printf("%s,%s,%s\n", $col1_title, $col2_title, $col3_title);
}
else { #any line other than 1,2,3
$col2_value = $a[0]; #Grab value of day type
$col3_value = $a[1]; #Grab value of day
#print out 101, type value, day value
printf("%s,%s,%s\n", $col1_value, $col2_value, $col3_value);
}
}
You run the program passing the file using standard input...
cat pay1 | perl pay1.pl
Output is...
EmployeeID,Day_type, day
101,vacation,1/2/2009
101,sick day, 3/2/2009
101,personal day, 4/5/2009
101,jury duty day, 5/5/2009