The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
More than transposing! bulash UNIX Desktop for Dummies Questions & Answers 3 04-11-2008 02:20 PM
Transposing string unibboy Shell Programming and Scripting 3 02-13-2008 03:12 PM
Major Awk problems (Searching, If statements, transposing etc.) Blivo Shell Programming and Scripting 2 09-05-2007 03:41 AM
Another transposing issue stevesmith Shell Programming and Scripting 14 09-16-2006 01:48 AM
transposing letters myscsa2004 Shell Programming and Scripting 4 05-12-2004 07:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #22  
Old 08-04-2005
Registered User
 

Join Date: Jul 2005
Posts: 37
it didn't work. there are uneven values in eash row, some row have 500 records, some have 200, i dont' know if that's problem.

the error is,

bash-2.03$ ./file_transpose
nawk: record `atcc_rma_pvsall_bot5...' has too many fields
input record number 3, file atcc_fidler_genename_markers
source line number 2

the code is,

###file transpose, colume to row
###from unix.com/Ygor, 07/29/2005

nawk -v OFS='\t' '{
for (f = 1; f <= NF; f++)
a[NR, f] = $f
}
NF > nf { nf = NF }
END {
for (f = 1; f <= nf; f++)
for (r = 1; r <= NR; r++)
printf a[r, f] (r==NR ? RS : OFS)
}' infile > outfile
Reply With Quote
Forum Sponsor
  #23  
Old 08-04-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
that is the problem - too many fields for the 'nawk' to handle.
if you have 'gawk' installed on your system - try that instead of 'nawk'.
or if on Solaris, try '/usr/xpg4/bin/awk'.

The other problem is that the solution assumes the consistent number of columns for ALL the rows.

Good luck.

P.S. for the future - pls don't repost already posted unmodified solutions - it clutters the thread.
Reply With Quote
  #24  
Old 08-04-2005
Registered User
 

Join Date: Jul 2005
Posts: 37
it worked! thank you so much. but only one problem left, some of the record being changed. for example,

input record c2 is mad1///mad2///mad3 (one record), output is mad1, ///, mad2, ///, mad3 (file records); can this be fixed? thanks again.

I got your point for post a request. Thanks.
Reply With Quote
  #25  
Old 08-04-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
I don't quite understand what you're saying, but you'll have to look at your input data and see the 'wrong' records "differ" from the rest - most likely this "difference" breaks the implementation.

Good luck.

Last edited by vgersh99; 08-05-2005 at 07:32 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0