Insert text in datafile with uneven columns


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Insert text in datafile with uneven columns
# 1  
Old 12-29-2009
Insert text in datafile with uneven columns

Dear Unix Gurus,

I have a dataset consisting of a number of uneven columns. What I would like to do is fill up the missing rows with an arbitrary text of fixed value so that all columns now have an equal number of rows.

for example, in the sample datafile below...

Code:
1.0 1.3 0.25 2.2
2.0 1.1 0.25 3.1
3.0 1.2 0.25 2.1
4.0 1.4 0.25 0.1
5.0 1.5 0.25 0.13
8.0 1.7 0.25 0.16
11.5 4.3 0.25 0.1
-11.5 3.3 0.25 0.15
-12.5 4.3 0.25 0.1
-13.5 1.3 0.25 0.3
-14.5 1.4 0.25 0.2
-15.5 1.7 0.25 0.0
3.5 1.3 0.25 0.11
5.5 1.3 0.25 0.13
    5.3 0.25 0.15
    4.3 0.25 0.17
    2.3      0.11
    3.3      0.16
    1.1      
    1.4      
    1.8

I would like to fill all the blank rows with -999.99 so I have 4 columns of data, each with 21 rows of text.
Inserting an additional column is trivial enough but filling in the blank spaces of an existing column of data with an arbitrary number is beyond me at this time. I need help.....!!Smilie

cheers.
# 2  
Old 12-29-2009
how you wanna generate that arbitrary number??
can you elaborate bit more??
# 3  
Old 12-29-2009
Hi,

I want to insert a pre-defined number, i.e. in this case "-999.99", into all blank rows.

The reason for this is that I want to use the datafile to generate histograms - one for each data column. Problem is the histograms must all have the same number of entries or else my code fails. So I need to insert an arbitrary high number say, 999 or -999 to fill up the blank rows. On generating the histograms I can then select the data I'm interested in using cuts.

Cheers
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Match and insert columns

Hi, I've got two files to match. File one: a1 b c d e a2 b c d e a3 b c d e a4 b c d e and file 2 a1 1 2 3 4 a2 5 6 7 8 a3 9 10 11 12 a4 1 2 3 4 I need to match them by the first column and add the four columns of file 2 to the file 1 so that those added columns go as columns... (5 Replies)
Discussion started by: zajtat
5 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Uneven column to row conversion

Hi Unix Forum, I have a relatively easy question i suppose for which, however, until now i could not find a solution. I am working with a program that will give me an output file similar to the following: A 1 2 3 4 B 1 2 3 4 C 1 (9 Replies)
Discussion started by: Leander
9 Replies

3. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

4. Shell Programming and Scripting

sorting the datafile in an order given in second datafile

Hi, I have two files: first input file is having 7-8 columns, and second data file is like I want to arrange my datafile1 in the order given in second data file, by comparing the seconddatafile with the second column of first file and print the entire line....also if any... (2 Replies)
Discussion started by: CAch
2 Replies

5. UNIX for Dummies Questions & Answers

How to insert alternative columns and sort text from first column to second?

Hi Everybody, I am just new to UNIX as well as to this forum. I have a text file with 10,000 coloumns and each coloumn contains values separated by space. I want to separate them into new coloumns..the file is something like this as ad af 1 A as ad af 1 D ... ... 1 and A are in one... (7 Replies)
Discussion started by: Unilearn
7 Replies

6. Shell Programming and Scripting

Reversing numbers in a datafile of rows and columns

Hello, I've tried searching the forum for an answer to my question, but without any luck... I have a datafile looking simplified as follows: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 I want to reverse it by rearranging all the numbers from last to... (16 Replies)
Discussion started by: mattings
16 Replies

7. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

8. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

9. AIX

How to insert dummy columns

Hi My requirement is as follows, I have a input feed coming for X as A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; any other feed coming from Y is as ... (2 Replies)
Discussion started by: smolgara
2 Replies

10. Shell Programming and Scripting

Combine a datafile with Master datafile, emergent!

Hi guys, my supervisor has asked me to solve the problem in 7 days, I've taken 3 days to think about it but couldn't figure out any idea. Please give me some thoughts with the following problem, I have index.database that has only index date: 1994 1995 1996 1997 1998 1999 I have... (6 Replies)
Discussion started by: onthetopo
6 Replies
Login or Register to Ask a Question