Converted repeated rows into splitted columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converted repeated rows into splitted columns
# 1  
Old 03-27-2011
Converted repeated rows into splitted columns

Dear Friends,

I have an input file contains lot of datas, which is like repaeated rows report.

The output file need to have column wise report, rather than row-wise.

Code:
Input File
random line 1
random line 2
random line 3
-------------------------------------
Start line 1.1 (9.9)                                  20:33:03           Mon 07-26-2010
--------------------------------
config 		VM:  576 KB + 68/89 MB, TH 4 [TT 9+0] [T2 7+0]
File Name 	ui
File Size	123bytes

param	sl 1.00 x 1.90

Initial extent	(0.5)
changed 	(0.9)
-
-
-
--

-------------------------------------
Start line 1.1 (9.9)                                  24:31:03          Mon 07-26-2010
--------------------------------
config 		VM:  676 KB + 68/89 MB, TH 4 [TT 9+0] [T2 7+0]
File Name 	oi
File Size	456bytes

param	sl 1.01 x 1.90

Initial extent	(0.7)
changed 	(0.1)
-
-
-
--




Output required

COl1	TIME	 DATE	Config	FileName  	FileSize  	par
		
1.1(9.9)   20:33:03   Mon 07-26-2010   VM:--	ui 	123	S--
1.1(9.9)   24:31:03   Mon 07-26-2010     VM:..	oi      456   S --

Thanks in advance
VasanthSmilie
# 2  
Old 03-27-2011
Hi vasanth.v,

You can try with:
Code:
awk 'BEGIN{print "COl1|TIME|DATE|Config|FileName|FileSize|par"}
 {sub(/ \(/,"(")}
 /^Start line/{a=$3"|"$4"|"$5" "$6}
 /^config/{a=a"|"$2"--"}
 /File Name|File Size/{a=a"|"$3}
 /^param/{print a"|"$2"--";a=""}' inputfile
COl1|TIME|DATE|Config|FileName|FileSize|par
1.1(9.9)|20:33:03|Mon 07-26-2010|VM:--|ui|123bytes|sl--
1.1(9.9)|24:31:03|Mon 07-26-2010|VM:--|oi|456bytes|sl--


In order to avoid confuse fields, I've separate the output fields with |. If you need separated with spaces, please
replace every
| with one space in the BEGIN line and replace every "|" with " "

Hope it helps,

Regards

Last edited by cgkmal; 03-27-2011 at 05:09 AM..
This User Gave Thanks to cgkmal For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help - manipulate data by columns and repeated

Hello good afternoon to everyone. I'm new to the forum and would like to request your help in handling data. I hope my English is clear. I have a file (Dato01.txt) to contine the following structure. # Col1 - Col2 - Col3 - Col4 Patricia started Jun 22 05:22:58 Carolina started Jun... (5 Replies)
Discussion started by: kelevra
5 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Find repeated word and take sum of the second field to it ,for all the repeated words in awk

Hi below is the input file, i need to find repeated words and sum up the values of it which is second field from the repeated work.Im trying but getting no where close to it.Kindly give me a hint on how to go about it Input fruits,apple,20,fruits,mango,20,veg,carrot,12,veg,raddish,30... (11 Replies)
Discussion started by: 100bees
11 Replies

5. 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

6. Shell Programming and Scripting

Transposing Repeated Rows to Columns.

I have 1000s of these rows that I would like to transpose to columns. However I would like the transpose every 3 consecutive rows to columns like below, sorted by column 3 and provide a total for each occurrences. Finally I would like a grand total of column 3. 21|FE|41|0B 50\65\78 15... (2 Replies)
Discussion started by: ravzter
2 Replies

7. Shell Programming and Scripting

Rows into columns?

I have a file thats space delimited that looks something like this: Joe Smith jsmith 43234 bill1;bill2;read;read2;schedule Andy Summers asummers 11232 bill1;read Beth McConnel bmconnel 43443 read;read2;schedule;bill Susan Fowler sfowler 09332 bill1;read;schedule I need to... (8 Replies)
Discussion started by: regexnub
8 Replies

8. Shell Programming and Scripting

comparing the values of repeated keys in multiple columns

Hi Guyz The 1st column of the input file has repeated keys like x,y and z. The ist task is if the 1st column has unique key (say x) and then need to consider 4th column, if it is + symbol then subtract 2nd column value with 3rd column value (we will get 2(10-8)) or if it is - symbol subtract 3rd... (3 Replies)
Discussion started by: repinementer
3 Replies

9. Shell Programming and Scripting

So I converted columns to rows but I want it to be tab delimited and also I want.....

Hi, So my file looks like this: title number JR 2 JR 2 JR 4 JR 5 NM 5 NM 8 NM 2 NM 8 I used this line that I wrote to convert it to rows so it will look like this: awk -F"\t" '!/^$/{a=a" "$3} END {for ( i in a) {print i,a}}' occ_output.tab > test.txt JR 2 2 4 5 NM 5 8... (4 Replies)
Discussion started by: kylle345
4 Replies

10. Shell Programming and Scripting

Delete repeated rows from a file

Hi everybody: Could anybody tell me how I can delete repeated rows from a file?, this is, for exemple I have a file like this: 0.490 958.73 281.85 6.67985 0.002481 0.490 954.833 283.991 8.73019 0.002471 0.590 950.504 286.241 6.61451 0.002461 0.690 939.323 286.112 6.16451 0.00246 0.790... (8 Replies)
Discussion started by: tonet
8 Replies
Login or Register to Ask a Question