Cut and paste data in matrix form


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cut and paste data in matrix form
# 1  
Old 01-20-2010
Cut and paste data in matrix form

I have large formatted data file with five columns. This has to be rearranged in lower order matrix form as shown below for sample data.


1 2 3 4 5
1.0
3.0 2.0
5.0 3.0 2.0
4.0 3.0 1.0 6.0
2.0 3.0 4.0 5.0 1.0
1.0 4.0 2.0 3.0 5.0
3.0 5.0 4.0 2.0 8.0
1.0 3.0 2.0 4.0 5.0
2.0 1.0 3.0 7.0 8.0
6 7 8 9
1.0
3.0 5.0
1.0 3.0 2.0
2.0 3.0 4.0 5.0


1 2 3 4 5 6 7 8 9
1.0
3.0 2.0
5.0 3.0 2.0
4.0 3.0 1.0 6.0
2.0 3.0 4.0 5.0 1.0
1.0 4.0 2.0 3.0 5.0 1.0
3.0 5.0 4.0 2.0 8.0 3.0 5.0
1.0 3.0 2.0 4.0 5.0 1.0 3.0 2.0
2.0 1.0 3.0 7.0 8.0 2.0 3.0 4.0 5.0


Thanks in advance,
Dhilip
# 2  
Old 01-20-2010
hello ,

Is this homework?
# 3  
Old 01-20-2010
No. This is not homework! Thanks.
# 4  
Old 01-20-2010
hello,

I would like to try to do it . seems like a great sudoku puzzle to me. but only I would like to know first that what kind of work involves this kind of number arrangements.

Cheers,
gaurav.
# 5  
Old 01-20-2010
Hello Gaurav,

I am extracting data from the results of quantum chemical calculations. Using grep and awk commands, I have printed the necessary data from the very large output in a new file. But the data is in five column format and I need this rearranged in a lower order matrix form. The matrix data becomes input for another fortran code for further calculation! The data shown above is only an example data. Hope this helps.

Many thanks.
Dhilip
# 6  
Old 01-20-2010
I try to understand your request. But it makes me confused.

In your sample file, there are not 5 columns every line. So what's your desired output?
# 7  
Old 01-20-2010
The last set varies between column 1 to 5. In the sample data, the last set has 4 columns (6 7 8 9).

For example, my input dat file has:

c1 c2 c3 c4 c5
.
.
c6 c7 c8 c9
.
.

And desired ouput is:

c1 c2 c3 c4 c5 c6 c7 c8 c9
.
.
.
.


Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match child with parents and form matrix

thank you for letting me join this forum, lots of learning opportunities looks like. Myself a biologist, very new into unix, so please excuse if I use incorrect language. I am using cygwin on windows, it can run perl, awk , sed etc. I have 2 files, the first sample sheet, tells which parent... (10 Replies)
Discussion started by: jalaj841
10 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. UNIX for Dummies Questions & Answers

Form balanced matrix by filtering data

I need to form a matrix out of unbalanced set of records. First eliminate the sample that do not have at least 3 variables (col2). So, in the example, samples 4 and 5 get eliminated. Then form a matrix of values (col3) from the samples using only variables that are present accross all samples.... (3 Replies)
Discussion started by: senhia83
3 Replies

4. Shell Programming and Scripting

Cut command in a matrix

Hi All, I want to display row=2 and column=1 where value=10 with the help of cut command, Please advice me 1 2 3 4 5 6 7 8 9 10 11 12 (2 Replies)
Discussion started by: raghur77
2 Replies

5. Shell Programming and Scripting

Transpose Data form Different form

HI Guys, I have data in File A.txt RL03 RL03_A_1 RL03_B_1 RL03_C_1 RL03 -119.8 -119.5 -119.5 RL07 RL07_A_1 RL07_B_1 RL07_C_1 RL07 -119.3 -119.5 -119.5 RL15 RL15_A_1 RL15_C_1 RL15 -120.5 -119.4 RL16... (2 Replies)
Discussion started by: asavaliya
2 Replies

6. Shell Programming and Scripting

Cut and paste data in new file

HI Guys, I have file A: Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo Abc Abc Klooo I want file B Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo File A is now 1 lines Abc Abc Klooo Cut all lines which have xyz... (2 Replies)
Discussion started by: asavaliya
2 Replies

7. Shell Programming and Scripting

Reformatting data in matrix form

Hi, Some assistance with respect to the following problem will be very helpful. I want to reformat my dataset in the following manner for subsequent analysis. I have first column values (which repeat for each value of 2nd column) which are names, the second column specifies position ad the... (1 Reply)
Discussion started by: newbie83
1 Replies

8. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

9. Shell Programming and Scripting

cut and paste?

hi, I have a file with content like this for an employee: EmployeeID 101 Day_type, day vacation,1/2/2009 sick day, 3/2/2009 personal day, 4/5/2009 jury duty day, 5/5/2009 how do I make the result to show: EmployeeID,Day_type,day 101,vacation,1/2/2009 101,sick day,... (6 Replies)
Discussion started by: jbchen
6 Replies

10. UNIX for Dummies Questions & Answers

changing data into matrix form

Hi, I have a file whose structure is like this 7 7 1 2 3 4 5 1 3 4 8 6 1 4 5 6 0 2 6 8 3 8 2 5 7 8 0 5 7 9 4 1 3 8 0 2 2 3 5 6 8 basically first two row tell the number of rows and column but the data following them are not arranged in that format. now i want to create another... (1 Reply)
Discussion started by: g0600014
1 Replies
Login or Register to Ask a Question