convert text contents/paragraph to cvs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert text contents/paragraph to cvs
# 8  
Old 11-24-2008
hi cherry, thanks for the script, but the script produced nothing:

xajax@userver:~$ perl csv.perl file
xajax@userver:~$
# 9  
Old 11-24-2008
dennis,

i tried your awk script after removed all the blank lines but still cannot, any solution for this ? really appreciate anyone help on this. thanks
# 10  
Old 11-24-2008
Quote:
Originally Posted by xajax7
dennis,

i tried your awk script after removed all the blank lines but still cannot, any solution for this ? really appreciate anyone help on this. thanks
It works well for me..

Input:
Quote:
Fri Aug 01 00:01:19 2008
NAS-IP-Address = 172.16.160.1
Class = "P1-SHT-AAA01;1217116976;70999"
Calling-Station-Id = "00-11-FB-01-03-06"
Acct-Status-Type = Start
Acct-Session-Id = "31908b485a370000"
Framed-IP-Address = 172.16.160.10
BS-ID = 000012A00433
User-Name = "user1"
Fri Aug 01 00:02:02 2008
NAS-IP-Address = 172.16.160.1
Class = "P1-SHT-AAA01;1217116976;71005"
Calling-Station-Id = "00-11-FB-01-03-06"
Acct-Status-Type = Stop
Acct-Session-Id = "31908b485d370000"
Framed-IP-Address = 172.16.160.20
BS-ID = 000012A00413
User-Name = "user2"
Fri Aug 01 00:02:02 2008
NAS-IP-Address = 172.16.160.1
Class = "P1-SHT-AAA01;1217116976;71005"
Calling-Station-Id = "00-11-FB-01-03-06"
Acct-Status-Type = Stop
Acct-Session-Id = "31908b485d370000"
Framed-IP-Address = 172.16.160.20
BS-ID = 000012A00413
User-Name = "user3"
o/p

Quote:
01-08-2008;172.16.160.1;P1-SHT-AAA01;1217116976;70999;00-11-FB-01-03-06;Start;31908b485a370000;172.16.160.10;000012A00433;user1
01-08-2008;172.16.160.1;P1-SHT-AAA01;1217116976;71005;00-11-FB-01-03-06;Stop;31908b485d370000;172.16.160.20;000012A00413;user2
01-08-2008;172.16.160.1;P1-SHT-AAA01;1217116976;71005;00-11-FB-01-03-06;Stop;31908b485d370000;172.16.160.20;000012A00413;user3
# 11  
Old 11-24-2008
hi dennis,

how to modified your script to include date and time;.... in the output ? something like this

01-08-2008;00:01:19;172.16.160.1;P1-SHT-AAA01;1217116976;70999;00-11-FB-01-03-06;Start;31908b485a370000;172.16.160.10;000012A00433;user1

ouput ? actually i forgot to include the time column in my 1st question and apologize for that. thanks
# 12  
Old 11-25-2008
hi, I found the solution for date and time output, just expended/modified the +%d-%m-%Y to +%F;%d-%m-%Y . thanks all for the help on this.
# 13  
Old 02-19-2009
hi all,

me again, dennis's script working fine all the time except one, when the "User-Name" field contains some special character like {}$%!@#^&*(). how to prevent that to happen. sample data:

Fri Aug 01 00:02:02 2008
NAS-IP-Address = 172.16.160.1
Class = "P1-SHT-AAA01;1217116976;71005"
Calling-Station-Id = "00-11-FB-01-03-06"
Acct-Status-Type = Stop
Acct-Session-Id = "31908b485d370000"
Framed-IP-Address = 172.16.160.20
BS-ID = 000012A00413
User-Name = "{as=1}user3"

btw, the username value random generated by device. and here is the original awk script:

awk -F= '!/^$/{if ($0 !~ /=/) {str="date -d \""$0"\" \"+%F*%H:%M:%S\""; val=system(str); } else {print $2;} }' < $tmp/data.out.start.strip | xargs -n9 | tr " " "*"

thanks in advance.
# 14  
Old 02-19-2009
actually Iam getting the following errors:

xargs: unmatched double quote; by default quotes are special to xargs unless you use the -0 option

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print each paragraph in a text file into excel file

Hi, I have a below text file, which needs to be printed into attached excel file. Please help me. Thanks (4 Replies)
Discussion started by: prash358
4 Replies

2. Shell Programming and Scripting

Easy way to pull a paragraph from a text file?

I have a collection of text files that comprise a mailing list archive. I grep them to find an email that interests me, then open the file in a text editor to find the surrounding paragraph of text. Is there an easy way to do this from the shell instead? (2 Replies)
Discussion started by: CRGreathouse
2 Replies

3. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

4. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

5. Shell Programming and Scripting

Search for a particular string in a paragraph in a text

Hi all, i'm new to this community. I am trying to write a script which will fetch ftp completion time of a file from a paragraph of a big text file ( which contains multiple paragraphs) . Each paragraph will have ftp details.. Now I dont know how to fetch process time within a paragraph of... (3 Replies)
Discussion started by: prachiagra
3 Replies

6. Shell Programming and Scripting

Convert contents of file to lower case with SED

Hi I what to add option to existing sed code to convert target file to lower case #!/bin/ksh SOURCE_DATA_DEST=/ora TARGET_DATA_DEST=/home/oracle/alexz TARGET_DB_SID=T102_test sed -e "s/REUSE/SET/g" \ -e "s/NORESETLOGS/RESETLOGS/g" \ T102_ccf.sql > target.sql Thanks (2 Replies)
Discussion started by: zam
2 Replies

7. Shell Programming and Scripting

Need help in parsing text file contents

Hi, I need some help in extracting the Exception block between the lines 21 Feb 01:18:54:146 ERROR com.orbits.frameworks.integrationframework.ValidationException - Caught exception in validateRequest() (PID=565584) and 21 Feb 01:18:55:149 INFO ... (0 Replies)
Discussion started by: Alecs
0 Replies

8. Shell Programming and Scripting

extracting last paragraph from a text

Hi All, I want to extract last paragraph from a text for example aaaaa sadafsa sdfdsaf asfdsad asfdsfad asfdfsafd adfssas asdfsafdsa asfdasdfa sadfasdsaf i need the last paragraph how to do it using linux commands (1 Reply)
Discussion started by: uvrakesh
1 Replies

9. Shell Programming and Scripting

Convert a paragraph to single line

I need to check the count of pipes on each line of the data to make sure we 4 pipes if its less i need to keep adding the string to form a single line ( Need to join/ concat the below lines until i get the 4 pipes which is end of record ). This fields is basicall a memo where the user would have... (6 Replies)
Discussion started by: rimss
6 Replies

10. UNIX for Dummies Questions & Answers

How do I convert unix text to to win text?

How do I convert unix text files into readable text for windows. Dave (1 Reply)
Discussion started by: nucca
1 Replies
Login or Register to Ask a Question