How to split the 11 comma's with number into newlines?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to split the 11 comma's with number into newlines?
# 1  
Old 06-18-2011
How to split the 11 comma's with number into newlines?

Hi all,
This my requirement is to spilt the comma's into new line
my sample is
Code:
Name,india,ID,cost,Date,vadaloreOffset,neyveliCurveUnit,Riskcuddalore
,,,,,,,,,,,1,0.00576652,,,,,,,,,,,7,0.00625467,,,,,,,,,,,30,0.00832759,,,,,,,,,,,61,0.00977132

expected output to be like this
Code:
Name,india,ID,cost,Date,vadaloreOffset,neyveliCurveUnit,Riskcuddalore
,,,,,,,,,,,1,0.00576652
,,,,,,,,,,,7,0.00625467
,,,,,,,,,,,30,0.00832759
,,,,,,,,,,,61,0.00977132

note:11 commas are even
plz help my requirement(mostly unix command to be executed in post session command in informatica)
regards,
G

Last edited by koviraja; 06-19-2011 at 05:56 AM.. Reason: Code tags, please!
# 2  
Old 06-18-2011
Code:
perl -pe 's/(?<!^),{11}/\n$&/g' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 06-18-2011
GNU sed:
Code:
sed 's/,,,*/\n&/2g' infile

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to change comma delimeter in the file to number?

I have a file H,20180624200732,VPAS,TRANS_HDR,20180724, VPAS.TRANS_HDR.20180724.01.txt, ,93, T,1, I have to change and instead first comma put ",1" like below H,20180624200732,VPAS,TRANS_HDR,20180724, VPAS.TRANS_HDR.20180724.01.txt,1,93, T,1, I made sed "2s/, /,1/"... (8 Replies)
Discussion started by: digioleg54
8 Replies

2. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

3. Shell Programming and Scripting

Insert a new column with sequence number (Delimiter as comma)

Hi All, I have a file which has data like a,b c,d e,f g,h And I need to insert a new column at the begining with sequence no( 1 to n) 1,a,b 2,c,d 3,e,f 4,g,h Please let me know how to acheive this in unix (3 Replies)
Discussion started by: weknowd
3 Replies

4. Shell Programming and Scripting

Replace comma and blank with comma and number

I, I have a file and i need to replace comma and blank space with comma and 0. cat file.txt a,5 b,1 c, d, e,4 I need the output as cat file.txt a,5 b,1 c,0 d,0 (4 Replies)
Discussion started by: jaituteja
4 Replies

5. Shell Programming and Scripting

How to split the comma separated file?

Hi, I have a filein unix like ABC,CDE BCD,KHL and the output i need is like column1 column2 ABC,CDE ABC ABC,CDE CDE BCD,KHL BCD BCD,KHL KHL. Can some body help me out? Hi, The code is working fine. But in my file each row does not have always 1 comma. It may... (6 Replies)
Discussion started by: jagdishrout
6 Replies

6. Shell Programming and Scripting

Count number of column in a comma delimited file

I have a comma (,) delimited file. 106232145,"medicare","medicare,medicaid",789 I would like to count the number of fields in each line. I tried the below code awk -F ',' '{print NF-1}' This returns me the result as 5 instead of 4. This is because the awk takes... (9 Replies)
Discussion started by: machomaddy
9 Replies

7. Shell Programming and Scripting

Insert comma based on max number of column

Hi, I am new to unix shell shell scripting. I have a specific requirement where I need to append comma's based on the max number of column in the file. Eg: If my source file look something like this, sengwa,china tom,america,northamerica smith,america walter My output file... (8 Replies)
Discussion started by: nicholas_ejn
8 Replies

8. Shell Programming and Scripting

replacing comma's with newlines using sed

Hi All, silly question that I'm sure is easy to answer for a more experienced coder... I have a file called test.txt containing the following text... need, to, break, this, line, into, individual, lines using sed, I'd like to make the file look like this... need to break this line... (5 Replies)
Discussion started by: newbie_coder
5 Replies

9. Shell Programming and Scripting

Split by comma

Hi all, for i in `cat /tmp/tester.txt` do echo $i done The content of /tmp/tester.txt is as below 1001,asp 1002,java 1003,vc Now when I try the above program it gives me a output in the same way as below. 1001,asp 1002,java 1003,vc (2 Replies)
Discussion started by: mahalakshmi
2 Replies
Login or Register to Ask a Question