Phrase txt file row to column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Phrase txt file row to column
# 1  
Old 03-19-2015
Phrase txt file row to column

Hi Guys,

I have one Big txt file and i what to phrase specific part as below.

Input :-

Code:
[2015-02-11 16:15:03.872] Event
Event {
  recordLength 160118,
  recordType 411,
  eventId 3102118,
  INTERNAL_PER_RO_ME_TA {
    EVVXX_TIMESTAMP_HOUR 16,
    EVVXX_TIMESTAMP_MINUTE 15,
    EVVXX_TIMESTAMP_SECOND 3,
    EVVXX_TIMESTAMP_MILLISEC 872,
    EVVXX_SID 600102228,
    EVVXX_EVENT_VADU (0),
    EVVXX_GLOBAL_NB_ID 01219442,
    EVVXX_ENBS1APID unavailable,
    EVVXX_MMES1APID unavailable,
    EVVXX_GUMMEI unavailable,
    EVVXX_RAC_EEFAA 555586410,
    EVVXX_TRACE_RECORDING_SESSION_REFERENCE '00 00 00'H,
    EVVXX_TIMESTAMP_START_HOUR 0,
    EVVXX_TIMESTAMP_START_MINUTE 0,
    EVVXX_TIMESTAMP_START_SECOND 0,
    EVVXX_TIMESTAMP_START_MILLISEC 0,
    EVVXX_TA_INTERVAL 1000,
    EVENT_AAA unavailable,
    EVENT_AAA unavailable,
    EVENT_AAA unavailable
  }
}
[2015-02-11 16:15:03.872] Event
Event {
  recordLength 160119,
  recordType 411,
  eventId 3102118,
  INTERNAL_PER_RO_ME_TA {
    EVVXX_TIMESTAMP_HOUR 17,
    EVVXX_TIMESTAMP_MINUTE 15,
    EVVXX_TIMESTAMP_SECOND 4,
    EVVXX_TIMESTAMP_MILLISEC 872,
    EVVXX_SID 600102228,
    EVVXX_EVENT_VADU (0),
    EVVXX_GLOBAL_NB_ID 01219444,
    EVVXX_ENBS1APID unavailable,
    EVVXX_MMES1APID unavailable,
    EVVXX_GUMMEI unavailable,
    EVVXX_RAC_EEFAA 555586410,
    EVVXX_TRACE_RECORDING_SESSION_REFERENCE '00 00 00'H,
    EVVXX_TIMESTAMP_START_HOUR 0,
    EVVXX_TIMESTAMP_START_MINUTE 0,
    EVVXX_TIMESTAMP_START_SECOND 0,
    EVVXX_TIMESTAMP_START_MILLISEC 0,
    EVVXX_TA_INTERVAL 1000,
    EVENT_AAA unavailable,
    EVENT_AAA unavailable,
    EVENT_AAA unavailable
  }
}

Output :-


Code:
EVVXX_TIMESTAMP_HOUR	EVVXX_TIMESTAMP_MINUTE	EVVXX_TIMESTAMP_SECOND	EVVXX_TIMESTAMP_MILLISEC	EVVXX_SID	EVVXX_EVENT_VADU	EVVXX_GLOBAL_NB_ID	EVVXX_ENBS1APID	EVVXX_MMES1APID	EVVXX_GUMMEI	EVVXX_RAC_EEFAA	EVVXX_TRACE_RECORDING_SESSION_REFERENCE	EVVXX_TIMESTAMP_START_HOUR	EVVXX_TIMESTAMP_START_MINUTE	EVVXX_TIMESTAMP_START_SECOND	EVVXX_TIMESTAMP_START_MILLISEC	EVVXX_TA_INTERVAL	EVENT_AAA	EVENT_AAA	EVENT_AAA
16	15	3	872	600102228	0	1219442	unavailable	unavailable	unavailable	555586410	00 00 00'H	0	0	0	0	1000	unavailable	unavailable	unavailable
17	15	4	872	600102228	0	1219444	unavailable	unavailable	unavailable	555586410	00 00 00'H	0	0	0	0	1000	unavailable	unavailable	unavailable

# 2  
Old 03-19-2015
Are the lines within each Event record always in the same order?
Are there ever any missing lines within an Event record?
Are the field names always the same in every Event record?

What have you tried?
What operating system are you using?
What shell are you using?
# 3  
Old 03-19-2015
HI

I never phrase text file this is the first time i am doing it .

trying to do with Shell scripting.

I tried below awk command but it is not giving me proper output.

Code:
nawk -F'[\"\>\<]' -v OFS=';' 'BEGIN{print "'HD'" } /d/{a=$3} /INTERNAL_PER_RO_ME_TA/{b=$3}/EVVXX_TIMESTAMP_HOUR/{c=$3}/EVVXX_TIMESTAMP_MINUTE/{d=$3}/EVVXX_TIMESTAMP_SECOND/{print a,b,c,d,$3}' ET.txt > test.txt

# 4  
Old 03-19-2015
I asked six simple questions. You answered one of them. (And from your use of nawk we can guess that you're probably using some version of a Solaris operating system.)

Please answer the other five questions I asked, so we don't waste time working on solutions that can't possibly work if we guess wrong about your input file format and operating environment.
# 5  
Old 03-19-2015
Sorry for Not reading your all question

Are the lines within each Event record always in the same order? -- yes
Are there ever any missing lines within an Event record?--- NO- same input for all
Are the field names always the same in every Event record? --- yes same for all

What have you tried? learning stage so try to do small scripting with awk command
What operating system are you using? solaris don't know the version
What shell are you using? awk and sed
# 6  
Old 03-20-2015
Your sample input contains the following lines:
Code:
    EVVXX_EVENT_VADU (0),
    EVVXX_GLOBAL_NB_ID 01219444,
               and
    EVVXX_TRACE_RECORDING_SESSION_REFERENCE '00 00 00'H,

but the corresponding output fields are:
Code:
0	1219444	and	00 00 00'H

without parentheses, without the leading zero, and without the leading single quote. Am I correct in assuming that the sample output is incorrect and that the sample input should be copied verbatim to the corresponding output fields? Or, is there some special processing that is supposed to happen for some fields that you didn't mention?

Last edited by Don Cragun; 03-20-2015 at 03:13 AM..
# 7  
Old 03-20-2015
Please note the questions asked in post #6 in this thread.

I thought I was having problems in my awk script, but it turns out I was seeing a problem in my terminal emulator... Is the following acceptable output from the sample data you provided? If not, please explain the rules for converting the data from what was found in your sample input to the data that needs to be presented in your output.
Code:
EVVXX_TIMESTAMP_HOUR	EVVXX_TIMESTAMP_MINUTE	EVVXX_TIMESTAMP_SECOND	EVVXX_TIMESTAMP_MILLISEC	EVVXX_SID	EVVXX_EVENT_VADU	EVVXX_GLOBAL_NB_ID	EVVXX_ENBS1APID	EVVXX_MMES1APID	EVVXX_GUMMEI	EVVXX_RAC_EEFAA	EVVXX_TRACE_RECORDING_SESSION_REFERENCE	EVVXX_TIMESTAMP_START_HOUR	EVVXX_TIMESTAMP_START_MINUTE	EVVXX_TIMESTAMP_START_SECOND	EVVXX_TIMESTAMP_START_MILLISEC	EVVXX_TA_INTERVAL	EVENT_AAA	EVENT_AAA	EVENT_AAA
16	15	3	872	600102228	(0)	01219442	unavailable	unavailable	unavailable	555586410	'00 00 00'H	0	0	0	0	1000	unavailable	unavailable	unavailable
17	15	4	872	600102228	(0)	01219444	unavailable	unavailable	unavailable	555586410	'00 00 00'H	0	0	0	0	1000	unavailable	unavailable	unavailable

The three fields on each of the last two line marked in red above match the input samples your provided, but do NOT match the output you said you want in those fields.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk help: how to pull phrase and one column from line above?

Hi everyone, Here's my awk statement so far: awk '/TOTAL TYPE:/{print x;print};{x=$0}' file1 >file2 'file1' has too much proprietary data in it to include here, so let's go with the output from code above. It looks like this: 123456 JAMES T KIRK D ... (2 Replies)
Discussion started by: Scottie1954
2 Replies

2. Shell Programming and Scripting

How to find a phrase and pull all lines that follow until the phrase occurs again?

I want to burst a report by using the page number value in the report header. Each section starts with *PAGE NO:* 1 Each section might have several pages, but the next section always starts back at 1. So I want to find the "*PAGE NO:* 1" value and pull all lines that follow until "*PAGE NO:* 1"... (4 Replies)
Discussion started by: Scottie1954
4 Replies

3. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

4. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

5. UNIX for Dummies Questions & Answers

Add a new column to txt file containing filename

I would like help adding a new column to a large txt file (~10MB) that contains the filename. I have searched other posts but have not found an adequate solution. I need this extra column so I can concatenate >100 files and perform awk searches on this large file. My current txt file look... (4 Replies)
Discussion started by: kellywilliams
4 Replies

6. AIX

Adding column in a .txt file

Helle, I want to create a .ksh script in order to realize the following : I have a .txt file organized in a bloc of information, each bloc start with 000 as following: 000... 001... 003... 004... 000... 001... 003... 004... . . My aim is to add a new... (6 Replies)
Discussion started by: zainab2006
6 Replies

7. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

8. Shell Programming and Scripting

How to get the first column from the txt file using unix command?

Hi All, I have the file like this (file name is : tem_text) no Id name ccy ------- ---- ------------------- -------- 7777 17 India Overseas Partners 500INR I want to retreive the third colimn of from the above text file if i use the basic awk command cat... (4 Replies)
Discussion started by: psiva_arul
4 Replies

9. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

10. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
Login or Register to Ask a Question