Convert Columns to rows

January 14, 2010 at 05:44:44
Specs: Unix
I want to use Ask shell script to convert following input file contents

2010-01-15 T 11:12 – ignore this line
Attrib1 = 123456789
Attrib2 = 901122334
Attribute 3 =surname
list = 4
Listings = 10

2010-01-15 T 12:12 – ignore this line
Attrib1 = 123
Attrib2 = 901122334
Attribute 3 = Name
list = 2
Listings = 3

to comma seperated file

123456789, 901122334,Surname,4,10
123, 901122334,Name,2,3

please advice


See More: Convert Columns to rows

Report •

#1
January 14, 2010 at 18:44:47
I put your data in a file named junk.data.3. This produces what you want.

#!/bin/ksh

exec 3<junk.data.3

while read -r -u3 line
do
case $line in

*=* ) printline="$printline${line##*=},"
;;
"" ) print ${printline%,*}
unset printline
;;
* ) print $printline
esac

done
print ${printline%,*}


Report •

#2
January 14, 2010 at 19:38:48
perfect solution... :)
Thanks thepubba1

Report •
Related Solutions


Ask Question