Hello all, I'm working on an attendance callout script for a school district. I need to change our current layout for the vendor. Currently the data is in the form of:
studentid,period,building,
Heres a sample of some made up records:
500,1,30,
500,2,30,
500,3,30,
500,6,30,
7899,2,31,
9021,1,33,
9021,6,33,
907711,5,40,
907711,6,40,
I need to reformat this, omitting the header row, to look like the following:
500,1,2,3,6,30,
7899,2,31,
9021,1,6,33,
907711,5,6,40,
I've done stuff like this with awk in the past when the number of fields were a constant. Just not sure how to loop through this when the number of fields vary. The kids can have an unexcused in any number of periods throughout the day. Some of our buildings have over 9 periods configured for attendance purposes as well.
If anyone has some code to get me going in the right direction that would be great.
I will read the file first then do something like this to compare the current record with the next record to verify its the same kid. (beyond that I'm not sure how to proceed)
awk -F, '
$1 == lastid {
do something
}
$1 != lastid {
lastid=$1
do something
}'
Thanks,