Making ths CSV


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Making ths CSV
# 1  
Old 04-30-2013
Making ths CSV

can any body help me on this:

Code:
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              13
SGSAP:     MT_SMS_PAGING               52
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             54
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              5
SGSAP:     MT_SMS_PAGING               25
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             19
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              4
SGSAP:     MT_SMS_PAGING               2
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             5
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              1
SGSAP:     MT_SMS_PAGING
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             1
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              3
SGSAP:     MT_SMS_PAGING               8
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             11
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              1
SGSAP:     MT_SMS_PAGING               3
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             4
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              1
SGSAP:     MT_SMS_PAGING               7
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             8
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              8
SGSAP:     MT_SMS_PAGING               13
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             16
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              14
SGSAP:     MT_SMS_PAGING               38
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             43
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              21
SGSAP:     MT_SMS_PAGING               67
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             54
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              35
SGSAP:     MT_SMS_PAGING               67
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             86
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              47
SGSAP:     MT_SMS_PAGING               94
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             124
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              54
SGSAP:     MT_SMS_PAGING               117
SGSAP:     MT_USSD_PAGING
SGSAP:     MT_SERVICE_REQ             150
SGSAP:     MT_OTHER_PAGING             0
SGSAP:     MT_CALL_PAGING              83
SGSAP:     MT_SMS_PAGING               210
SGSAP:     MT_USSD_PAGING

i want to create a csv file having
Code:
MT_OTHER_PAGING    MT_CALL_PAGING   MT_CALL_PAGING
150                                    0                                    83
124                                   0                                     54

Moderator's Comments:
Mod Comment Use code tags, please!

Last edited by radoulov; 04-30-2013 at 06:40 AM..
# 2  
Old 04-30-2013
Whats the criteria behind those values under the columns? also you want same column twice? (MT_CALL_PAGING MT_CALL_PAGING
)
# 3  
Old 04-30-2013
no i want clomns will be printed once
but the value will be diff as i have in the file
# 4  
Old 04-30-2013
My question is more around the values which have written in desired o/p.. How exactly you arrived to those values?
# 5  
Old 04-30-2013
i have that file...which contains the value

i need to make it CSV format.........

in csv it should look like :
MT_OTHER_PAGING MT_CALL_PAGING MT_CALL_PAGING 150 0 83 124 0 54
# 6  
Old 04-30-2013
Like this? CSV=Comma-separated values
Code:
awk 'BEGIN {print "MT_OTHER_PAGING,MT_CALL_PAGING,MT_SMS_PAGING,MT_USSD_PAGING,MT_SERVICE_REQ"} {printf "%s,",$3; if ($2=="MT_SERVICE_REQ") print ""}' file
MT_OTHER_PAGING,MT_CALL_PAGING,MT_SMS_PAGING,MT_USSD_PAGING,MT_SERVICE_REQ
0,13,52,,54,
0,5,25,,19,
0,4,2,,5,
0,1,,,1,
0,3,8,,11,
0,1,3,,4,
0,1,7,,8,
0,8,13,,16,
0,14,38,,43,
0,21,67,,54,
0,35,67,,86,
0,47,94,,124,
0,54,117,,150,
0,83,210,,,

# 7  
Old 04-30-2013
hi Jotne
thank you.............


but while running the script .......the result is coming like following :
Code:
MT_OTHER_PAGING,MT_CALL_PAGING,MT_SMS_PAGING,MT_USSD_PAGING,MT_SERVICE_REQ
,Following,,,0,13,52,,54,
0,5,25,,19,
0,4,2,,5,

=======

Following,, -> this is coming
and ,, are coming..it has to come ,

Last edited by Franklin52; 05-02-2013 at 03:39 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

2. Shell Programming and Scripting

Compare 2 csv files in ksh and o/p the difference in a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 The... (7 Replies)
Discussion started by: Naresh101
7 Replies

3. Shell Programming and Scripting

Comparing 2 CSV files and sending the difference to a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 ... (1 Reply)
Discussion started by: Naresh101
1 Replies

4. Shell Programming and Scripting

Reading from a CSV and writing in same CSV file

Hi, I am tryng to read from a csv file and based on some grep command output I will modify one of the column in the same csv. Example:- Input CSV:- 20120829001415,noneAA,google.com 20120829001415,dfsafds,google.com 20120829001415,noneAA,google.com Intermediate Step:- If 2nd column of... (3 Replies)
Discussion started by: kmajumder
3 Replies

5. Shell Programming and Scripting

awk read column csv and search in other csv

hi, someone to know how can i read a specific column of csv file and search the value in other csv columns if exist the value in the second csv copy entire row with all field in a new csv file. i suppose that its possible using awk but i m not expertise thanks in advance (8 Replies)
Discussion started by: giankan
8 Replies

6. Shell Programming and Scripting

Perl search csv fileA where two strings exist on another csv fileB

Hi I have two csv files, with the following formats: FileA.log: Application, This occured blah Application, That occured blah Application, Also this AnotherLog, Bob did this AnotherLog, Dave did that FileB.log: Uk, London, Application, datetime, LaterDateTime, Today it had'nt... (8 Replies)
Discussion started by: PerlNewbRP
8 Replies

7. Shell Programming and Scripting

CSV to SQL insert: Awk for strings with multiple lines in csv

Hi Fellows, I have been struggling to fix an issue in csv records to compose sql statements and have been really losing sleep over it. Here is the problem: I have csv files in the following pipe-delimited format: Column1|Column2|Column3|Column4|NEWLINE Address Type|some descriptive... (4 Replies)
Discussion started by: khayal
4 Replies

8. Shell Programming and Scripting

2 problems: Mailing CSV file / parsing CSV for display

I have been trying to find a good solution for this seemingly simple task for 2 days, and I'm giving up and posting a thread. I hope someone can help me out! I'm on HPUX, using sqlplus, mailx, awk, have some other tools available, but can't install stuff that isn't already in place (without a... (6 Replies)
Discussion started by: soldstatic
6 Replies

9. Shell Programming and Scripting

Need to compare two csv files values and write into another csv file

Hi all, Am new to scripting. So i just need your ideas to help me out. Here goes my requirement. I have two csv files 1.csv 2.csv abc,1.24 abc,1 def,2.13 def,1 I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
Discussion started by: chinnahyd
2 Replies
Login or Register to Ask a Question