Visit Our UNIX and Linux User Community


How to change Raw data to Coloumn data fields


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to change Raw data to Coloumn data fields
# 1  
Old 08-29-2006
How to change Raw data to Coloumn data fields

Dear All,

I have some data file.see below.

--------------ALARM CLEARING FROM SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN--------------
Alarm Record ID: 25196304
Event Time: 2006-08-28 13:41:35
Event Type: Processing error alarm
Object of Reference: SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN
Perceived Severity: Cleared
Probable Cause: Threshold Crossed
Specific Problem: nocSupervisedMeasMin

Problem Text:
Measurement type gprsMmSgsnUnsuccessfulAttachRequests has exceeded its threshold.

--------------ALARM END--------------
--------------ALARM CLEARING FROM SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN--------------
Alarm Record ID: 25203271
Event Time: 2006-08-29 08:37:24
Event Type: Processing error alarm
Object of Reference: SubNetwork=ONRM_RootMo,SubNetwork=AXE,ManagedElement=CGSN
Perceived Severity: Cleared
Probable Cause: Threshold Crossed
Specific Problem: nocSupervisedMeasMin

Problem Text:
Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.

--------------ALARM END--------------


I want to make it like this.see below.

Alarm Record ID Event Time Event Type --- --- ---
25196304 2006-08-28 13:41:35 Processing error alarm --- ---- ---
25203274 2006-08-29 08:37:24 ---- ---- ---- ---


How i can do it?

Help me.

Regards,
Nayanajith.
# 2  
Old 08-29-2006
Awk(gawk) based solution

Here's a crude solution in gnu awk(gawk). You can save the alarms in a file and will have to make a small change.

Quote:
Problem Text:
Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.
appears in 2 lines. Remove the new line character after : so that it reads

Quote:
Problem Text:Measurement type gprsSmSgsnUnsuccessfulActivations has exceeded its threshold.
Then try this code :

Code:
awk -F":" 'BEGIN{phead=0}
/ALARM CLEARING/,/ALARM END/{ 
if($0!~"ALARM CLEARING" && $0 !~ "ALARM END")
 {
  if($1!~"Record ID") {data=data"\t"$2; header=header"\t"$1}
  else {data=data$2; header=header$1}
 }
 if($0~/ALARM END/)
   {data=data"\n";
     if(phead==0) print header;phead=1;}
}
END{print data}' filename

Displays the fields as tab separated entries.

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change data in one column with data from another file's column

Hello, I have this file outputData: # cat /tmp/outputData __Capacity^6^NBSC01_Licences^L3_functionality_for_ESB_switch __Capacity^2100^NBSC01_Licences^Gb_over_IP __Capacity^1837^NBSC01_Licences^EDGE_BSS_Fnc __Capacity^1816^NBSC01_Licences^GPRS_CS3_and_CS4... (1 Reply)
Discussion started by: nypreH
1 Replies

2. Shell Programming and Scripting

Scrape 10 million pages and save the raw html data in mysql database

I have a list of 10 million page urls. I want those pages scraped and saved in the mysql database as raw html. I own a Linux VPS server with 1GB RAM and WHM/cPanel. I would like to scrape at least 100,000 urls in 24 hours. So can anyone give me some sample shell scripting code? (4 Replies)
Discussion started by: Viruthagiri
4 Replies

3. UNIX for Dummies Questions & Answers

How to make a CSV file from a Raw data

Hi Please help me on this.i have the Following data i want to make it CSV file by a Unix Shell Script. •msgType : 234 ( m_code : 0 # m_name : type # m_data : LOG ) pls help me on this (4 Replies)
Discussion started by: Aditya.Gurgaon
4 Replies

4. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

5. UNIX for Dummies Questions & Answers

Listing out three fields of data

How would I find three different fields in a data file such as first name, last name, credit card number in a particular file? Thanks in advance for your help (3 Replies)
Discussion started by: damion
3 Replies

6. Shell Programming and Scripting

Put raw data to column data

Dear all, I want below data to make it in column format.so i will see the data like this cdrID teleServiceCode chargedPartyNumber ... ... ... ... "egmailcom0w10ggzx00" 'sMS (5)' "716323770" "m17ifi5z30w0z6o7200" 'sMS (5)' ... (7 Replies)
Discussion started by: Nayanajith
7 Replies

7. Shell Programming and Scripting

raw data to column data

I have a data file like this. SDPINPUTCDR.SDPCallDetailRecord.chargeEventCDR { cdrID : "egmailcom0w10ggzx00" teleServiceCode : 'sMS (5)' chargedPartyNumber : "716323770" otherPartyNumber : "een@gmail.com" time : "084127" date : "20070319" duration : "0" extensionInt1 : '4'D }... (3 Replies)
Discussion started by: Nayanajith
3 Replies

8. UNIX for Dummies Questions & Answers

Remove Data from Fields

I would like some sugestions on how to solve the following problem with removing selected data from fields. Each day I receive a file containing 22,000 records that I use a combination of awk and the cut command to remove unwanted fields. This is a work in process as I learn more about awk, sed... (4 Replies)
Discussion started by: greengrass
4 Replies

9. UNIX for Advanced & Expert Users

copying data to raw devices using 'dd'

Hello all, I'm new here, so this information may exist elsewhere on this forum. If so, please point me in the right direction. Here's the problem. I'm trying to migrate Oracle data from an HP system to a Sun system using a raw device as a 'bridge' between the two systems. Both machines... (4 Replies)
Discussion started by: Neville
4 Replies

10. Solaris

Identifying new fields of data

i have hundreds of lines of formatted data with 10 different fields per line. the data is refreshed every few minutes and some fields in some lines may reflect new data. i'm looking for a sample of code that help me to identify those new fields so that i can write them to a file to indicate that... (0 Replies)
Discussion started by: davels
0 Replies

Featured Tech Videos