Sponsored Content
Top Forums Shell Programming and Scripting Copy data to CSV file from txt output Post 302966043 by Don Cragun on Sunday 7th of February 2016 05:14:22 AM
Old 02-07-2016
Quote:
Originally Posted by adgjmpt
Hi Everyone ,

Below is output from a TL1 , I want just the NE Name: and beside that the Temperature and the voltages in a csv file , Is this possible?



Code:

> act-user:AB1S2a:ArshadFO:493::**********;

   AB1S2a 2016-02-07 10:13:24
M  493 COMPLD
   "ArshadFO:2016-02-07 10-04-55,0"
;

   AB1S2a 2016-02-07 10:13:24
A  0 REPT EVT SESSION
   "AB1S2a:NO,"
   /* TL1 Agent Copyright (c) 1999-2007 Cisco Systems, Inc.


   QR3S2a 2016-02-07 10:34:53
A  0 REPT EVT SESSION
   "QR3S2a:NO,"
   /*

      User ArshadFO logged in from 172.17.11.72 */
;

   QR3S2a 2016-02-07 10:34:55
M  1 COMPLD
   ":SHELF,TEMPERATURE=24C,VOLTAGEA=53950,VOLTAGEB=53905,"
;
> 

   QR3S2a 2016-02-07 10:34:55
M  123 COMPLD
;

There is no NE Name: in any of seven different versions of your post to this point. Using the NE name: data from an earlier version of your post, you could try something like:
Code:
awk '
/NE name:/ {
	n = $4
}
/:SHELF,/ {
	split($0, t, /[=,]/)
	print n, t[3], t[5], t[7]
}' OFS=, file

producing the output:
Code:
AB1S2a,33C,54446,54418
AB2S2a,27C,54158,54119
NJRS2c,25C,54232,54244
QH1S2a,25C,53574,53572
QH2S2a,29C,54438,54484
QH3S2a,32C,54360,54391
QR1S2a,35C,54241,54223
QR2S2a,24C,54309,54250
QR3S2a,24C,53950,53905

from the sample data you had provided at that point.

Of course, I have no idea how to extract NE name: data from your current sample input file. So, this might or might not be of any use to you.

If you want to try this script with an earlier sample of your data on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
 

9 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

select data from oracle table and save the output as csv file

Hi I need to execute a select statement in a solaris environment with oracle database. The select statement returns number of rows of data. I need the data to be inserted into a CSV file with proper format. For that we normally use "You have to select all your columns as one big string,... (2 Replies)
Discussion started by: rdhanek
2 Replies

3. Shell Programming and Scripting

Get Data From CSV File and put into a txt file

Hi Guys, File A I have File A as CSV Format.... No R SS MK Par value S AL A1 PKL123 Lo12 1 S AL A2 PKl123 Lo34 22 S AL A3 PkLK234 Lo67 -34 S AL A4 PkLK235 Lo09 120 S AL A5 PkLK236 Lo76 19 S AL A6 PkLK237 Lo44 -17 S AL A7 PkLK238 Lo90 2 S AL A8 PkLK239 Lo34 -9 I want file B like... (4 Replies)
Discussion started by: asavaliya
4 Replies

4. Shell Programming and Scripting

Copy Data from CSV file to Excel Sheet using Perl

Hi All, Firstly I will like to wish A Happy New Year to all. Now my issue is I have one csv file say(data.csv) and one excel file say(result.xls) The result.xls contains two sheet name Sheet1 and Sheet2, Now What I am trying to do is to First I want to delete that data of Sheet2 if present any,... (6 Replies)
Discussion started by: adisky123
6 Replies

5. UNIX for Dummies Questions & Answers

Need help combining txt files w/ multiple lines into csv single cell - also need data merge

:confused:Hello -- i just joined the forums. I am a complete noob -- only about 1 week into learning how to program anything... and starting with linux. I am working in Linux terminal. I have a folder with a bunch of txt files. Each file has several lines of html code. I want to combine... (2 Replies)
Discussion started by: jetsetter
2 Replies

6. Shell Programming and Scripting

Shell script for .Txt to .csv conversion with data processing

Hi experts, I want to convert a txt file having rows and columns (CNAI_DUMP_raw.txt) by comparing it with another text file (paramaters.txt) and generate a output in CSV which contains only 3rd column from CNAI_DUMP_raw.txt, and the columns mentioned in parameters.txt. FYI: There are two... (16 Replies)
Discussion started by: Gautam Banerjee
16 Replies

7. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

8. Shell Programming and Scripting

Output large volume of data to CSV file

I have a program that output the ownership and permission on each directory and file on the server to a csv file. I am getting error message when I run the program. The program is not outputting to the csv file. Error: the file access permissions do not allow the specified action cannot... (2 Replies)
Discussion started by: dellanicholson
2 Replies

9. Programming

Python script to run multiple command and append data in output csv file

Experts, I am writing a script and able to write only small piece of code and not able to collect logic to complete this task. In input file have to look for name like like this (BGL_HSR_901_1AG_A_CR9KTR10) before sh iss neors. Record this (BGL_HSR_901_1AG_A_CR9KTR10) in csv file Now have to... (0 Replies)
Discussion started by: as7951
0 Replies
All times are GMT -4. The time now is 01:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy