Hi,
I have one tab delimited file which is having multiple store_ids in first column seprated by pipe.I want to split the file on the basis of store_id(separating 1st record in to 2 records ).
I tried some more options like below with using split,awk etc ,But not able to get proper output. can somebody please help here?
awk 'FS = "\t";{n=split($2,s,"|");for (i=1;i<=n;i++) {$2=s;print}}'
Input:
store_id Age_21_25 Age_26_35 Age_36_45 Age_46_55 Age_56_65
1000401164|689017 8.116937952 41.8758236 24.30776271 11.95505201 8.471244693
1000488334|1084206 7.114212034 57.5707557 17.80863244 8.561672677 4.061502426
1000774612|1125312 6.4755786 63.15054848 15.40059325 7.036513624 5.047765246
1000979214|1190013 6.181663241 44.56080063 21.15212533 13.05156994 9.326079288
|1081832 6.810393524 39.3111534 23.87784902 15.98099337 9.4109512
2000043615|970276 6.809158988 51.58667473 19.64147383 9.620136197 7.546592693
2000136868|8065019 9.962407379 37.94331719 19.7381623 14.41566889 11.06586732
2000186586|8075300|123456 7.13703001 38.0685379 23.06179155 14.16599508 10.76015759
output:
store_id Age_21_25 Age_26_35 Age_36_45 Age_46_55 Age_56_65
1000401164 8.116937952 41.8758236 24.30776271 11.95505201 8.471244693
689017 8.116937952 41.8758236 24.30776271 11.95505201 8.471244693
1000488334 7.114212034 57.5707557 17.80863244 8.561672677 4.061502426
1084206 7.114212034 57.5707557 17.80863244 8.561672677 4.061502426
1000774612 6.4755786 63.15054848 15.40059325 7.036513624 5.047765246
1125312 6.4755786 63.15054848 15.40059325 7.036513624 5.047765246
1000979214 6.181663241 44.56080063 21.15212533 13.05156994 9.326079288
1190013 6.181663241 44.56080063 21.15212533 13.05156994 9.326079288
1081832 6.810393524 39.3111534 23.87784902 15.98099337 9.4109512
2000043615 6.809158988 51.58667473 19.64147383 9.620136197 7.546592693
970276 6.809158988 51.58667473 19.64147383 9.620136197 7.546592693
2000136868 9.962407379 37.94331719 19.7381623 14.41566889 11.06586732
8065019 9.962407379 37.94331719 19.7381623 14.41566889 11.06586732
2000186586 7.13703001 38.0685379 23.06179155 14.16599508 10.76015759
8075300 7.13703001 38.0685379 23.06179155 14.16599508 10.76015759
123456 7.13703001 38.0685379 23.06179155 14.16599508 10.76015759