[Solved] Insert tabs as delimiter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Insert tabs as delimiter
# 8  
Old 01-27-2014
Quote:
Originally Posted by ritakadm
The code is working perfectly for a few lines the exits with the error

Code:
awk: rita.awk:9:  (FILENAME=GOdesc_switchgrass_forAgriGO_sortedongenes.txt FNR=471) fatal:  attempt to access field -2147483648

how do I identify FNR=471 ?
Code:
$ awk 'FNR==471' filename

This User Gave Thanks to Akshay Hegde For This Post:
# 9  
Old 01-27-2014
what does the line 471 look like?
Empty line?
# 10  
Old 01-27-2014
It just has the first two columns. sorry, I was not aware of this. can this be dealt with? just make the fields tab separated that is.
# 11  
Old 01-27-2014
Quote:
Originally Posted by ritakadm
It just has the first two columns. sorry, I was not aware of this. can this be dealt with? just make the fields tab separated that is.
Code:
BEGIN {
   OFS="\t"
   nk=split("biological_process cellular_component molecular_function", t, FS)
   for(i in t)
     keys[t[i]]
}
NF < 3 {gsub(FS, OFS); print;next}
{
   f3=frest=""
   for(i=3; !($i in keys); i++)
      f3=(f3)?f3 FS $i:$i

   key=$i

   for(i=i+2; i<=NF; i++)
      frest=(frest)?frest FS $i:$i

   print $1, $2, f3, key, frest
}

This User Gave Thanks to vgersh99 For This Post:
# 12  
Old 01-27-2014
thank you so very much
# 13  
Old 01-27-2014
Try also
Code:
sed -r 's/ /\t/;s/ /\t/;s/ (biological_process|cellular_component|molecular_function) /\t\1\t/' file|

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a value between two empty delimiter in the file.

Would like to insert value between two empty delimiter and at the very last too if empty. $ cat customerleft.tbl 300|Customer#000000300|I0fJfo60DRqQ|7|17-165-193-5964|8084.92|\N|p fluffily among the slyly express grouches. furiously express instruct||||||||||||||||||||||||\N... (3 Replies)
Discussion started by: Mannu2525
3 Replies

2. Shell Programming and Scripting

Insert a new column with sequence number (Delimiter as comma)

Hi All, I have a file which has data like a,b c,d e,f g,h And I need to insert a new column at the begining with sequence no( 1 to n) 1,a,b 2,c,d 3,e,f 4,g,h Please let me know how to acheive this in unix (3 Replies)
Discussion started by: weknowd
3 Replies

3. UNIX for Dummies Questions & Answers

[Solved] How to swap PIPE seperator delimiter?

I have file like below 1|4|OR|OLAP|INT|INT||CONSTANT|2012/08/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|55791|LNR| 2|4|OR|OLAP|CLR|CLR||CONSTANT|2012/09/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|57891|REGS|... (2 Replies)
Discussion started by: gkskumar
2 Replies

4. Shell Programming and Scripting

[Solved] How to use delimiter

Hi, I am using below script to get the below given output. But i am wondering how to pick the names from below output. Script: echo "dis ql(*) cluster(CT.CL.RIBRSBT3)"| runmqsc CT.QM.701t8|egrep QUEUE|sed -e 's/QUEUE(/ /'|sed -e 's/)/ /' Output: ... (10 Replies)
Discussion started by: darling
10 Replies

5. Shell Programming and Scripting

Selecting Specific Columns and Insert the delimiter TAB

Hi, I am writing a Perl Script for the below : I have a data file that consists of the header information which is 231 Lines and the footer information as 4 lines. The total number of line including the header and footer 1.2 Million with Pipe Delimited file. For example: Header Information:... (4 Replies)
Discussion started by: filter
4 Replies

6. Shell Programming and Scripting

insert delimiter

I have a data file that I would like to add delimiters to. Example: Turn This: 20110624000744000693000704000764 Into This: 20110624,000744,000693,000704,000764 I found this link but the only issue is I do not know how many colums I will have. The first field would needs to be 8... (9 Replies)
Discussion started by: oldman2
9 Replies

7. Shell Programming and Scripting

replace spaces/tabs with delimiter |

Hi, I'm looking for a command that replaces spaces/tabs with pipe symbol and store the result to the same file instead of routing it to another file. infile outfile Thanks. (11 Replies)
Discussion started by: dvah
11 Replies

8. UNIX for Advanced & Expert Users

Insert Delimiter at fixed locations in a flat file

Hi Can somebody help me with solution for this PLEASE? I have a flat file and need to insert delimiters at fixed positions in all the lines so that I can easily convert into EXCEL with columns defined as per their width. For Example Here is the file { kkjhdhal sdfewss sdtereetyw... (7 Replies)
Discussion started by: jd_mca
7 Replies

9. Shell Programming and Scripting

Insert Tabs / Indent text

Hi, i need replace the slash (/) with a newline (\n) and a tab (\t). With 'find -type f' in a folder i got this output: ./1999/01/file1 ./1999/01/file2 ./1999/02/file1 ./2000/04/file1 ./2000/04/file2 ./2000/04/file3 ./2000/04/file4 ./2000/06/file1 ./2000/06/file2 ./2000/06/file3... (8 Replies)
Discussion started by: Tonda
8 Replies

10. Shell Programming and Scripting

Insert text between delimiter

Can someone help me on this? I'm creating an Insert stmt script but Oracle does not accept blanks values. How can I insert the word null between two commas? I'm guessing awk or sed. Is there a good post or site with easy to understand info on awk and sed? I'm really new to unix scripts :D ... (5 Replies)
Discussion started by: ystee
5 Replies
Login or Register to Ask a Question