How to merge rows into columns ????


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to merge rows into columns ????
# 1  
Old 01-16-2009
Question How to merge rows into columns ????

Hi guz I want to merge multiple rows into a multiple columns based on the first column.
The file has symbol //
I want to break the symbool // and I nedd exactlynew column at that point
the output will be like this
please guyz help in this isssue!!!!!



merging rows into columns FIle1

a 1
b 2
c 3
d 4

//

a 9
b 44

//

c 5
d 8
c 4
d 0

Output


a b c d
1 2 3 4
9 44 5 8
4 0
# 2  
Old 01-16-2009
Add a new column where // is? Your output doesn't show that is what you want.. Could you please give a better example, something that is logical?
# 3  
Old 01-16-2009
Hi

I have a file with 2 columns. evry set in a column ends with a symbol //.
the first one with something like chr, chr no, chromosome name, cell no. cell no. etc and the second column has values belong to the first columnlike chr Xy, 22, 345,22222 etc. Some clumns have repeated but not duplicate values. with these I want to make file with first cloumn as first row and second olumn as second row and so on...

chr chrXY
chr no 22
chrname FUUR
Cell 224Neuron
Cell no 22222

//

chr chrYY
chr no 23
chrname FUUS
Cell 225Neuron
Cell no 22223

//

chr chrYY
chr no 24
chrname FUUT
Cell 226Neuron
Cell no 22222
Cell 227Neuron
Cell no 222245
Cell 230Neuron
Cell no 22245
//

chr chrYY
chr no 25
chrname RUUS
Cell 225Neuron
Cell no 52223


chr chr no chrname Cell Cell no
chrXY 22 FUUR 224Neuron 22222
chrYY 23 FUUS 225Neuron 22223
chrYY 24 FUUT 226Neuron 222222
227Neuron 222245
230Neuron 22245
chrYY 25 RUUS 225Neuron 52223
# 4  
Old 01-16-2009
227Neuron 222245
230Neuron 22245 will be in their successive related column.
some font error is preveting the alignment
# 5  
Old 01-16-2009

Output



chr .........chr no....... chrname ......Cell............. Cell no

chrXY....... 22 ............FUUR .........224Neuron..... 22222
chrYY .......23 .............FUUS .........225Neuron .....22223
chrYY....... 24 .............FUUT.......... 226Neuron.... 222222
...................................................227Neuron.... 222245
..................................................230Neuron ......22245
chrYY .......25............. RUUS ..........225Neuron ......52223
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Merge rows into one if first 2 columns match

Hi, I wanted to merge the content and below is input and required output info. Input: /hello,a,r /hello,a,L /hello,a,X /hi,b,v /hi,b,c O/p: /hello,a,r:L:X /hi,v,:v:c Use code tags, thanks. (6 Replies)
Discussion started by: ankitas
6 Replies

2. Shell Programming and Scripting

Merge files and remove duplicated rows

In a folder I'll several times daily receive new files that I want to combine into one big file, without any duplicate rows. The file name in the folder will look like e.q: MissingData_2014-08-25_09-30-18.txt MissingData_2014-08-25_09-30-14.txt MissingData_2014-08-26_09-30-12.txt The content... (9 Replies)
Discussion started by: Bergans
9 Replies

3. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

4. Shell Programming and Scripting

Merge matching rows

Hello, I need this output. thank you very much. input: Code: ***table***wood ***snack***top ***table***garfield ***big***zen ***table***cars output: Code: ***table***wood2345garfield2345cars ***snack***top ***big***zen (7 Replies)
Discussion started by: tara123
7 Replies

5. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

6. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

7. UNIX for Dummies Questions & Answers

Merge rows with common column

Dear all I have big file with two columns A_AA960715 GO:0006952 A_AA960715 GO:0008152 A_AA960715 GO:0016491 A_AA960715 GO:0007165 A_AA960715 GO:0005618 A_AA960716 GO:0006952 A_AA960716 GO:0005618 A_AA960716... (15 Replies)
Discussion started by: AAWT
15 Replies

8. Shell Programming and Scripting

merge similar rows

I have a large file (10M lines) that contains two columns: a frequency and a string, ex: 3 aaaaa 4 bbbbb 2 ccccc 5 aaaaa 1 ddddd 4 ccccc I need to merge the lines whose string part is the same, while updating the frequency. The output should look like this: 8 aaaaa 4 bbbbb 5 ccccc... (2 Replies)
Discussion started by: tootles564
2 Replies

9. Shell Programming and Scripting

Merge two rows using awk or python

Hi, Suppose I have a space delimited file like this: Serial# 1970 1971 1972 1973 1974 193532 21 2 X X X 200201 20 30 X X 40 200201 X X 13 15 X 393666 66 3 X X 5 ... (2 Replies)
Discussion started by: grossgermany
2 Replies

10. Shell Programming and Scripting

merge rows based on a common column

Hi guys, Please guide me if you have a solution to this problem. I have tried paste -s but it's not giving the desired output. I have a file with the following content- A123 box1 B345 bat2 C431 my_id A123 service C431 box1 A123 my_id I need two different outputs- OUTPUT1 A123... (6 Replies)
Discussion started by: smriti_shridhar
6 Replies
Login or Register to Ask a Question