want to remove comma present inside double qoute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting want to remove comma present inside double qoute
# 1  
Old 12-02-2011
want to remove comma present inside double qoute

Hi friends...

I have a dat file like below:-

test_file.dat
Code:
abc,ttt,"""123,89.98",yyu,opp
vvv,"23,76.68",w564,"54,98.87",985

i need the remove the comma present inside the double qoute as output:-
out_test_file.dat
Code:
abc,ttt,"""12389.98",yyu,opp
vvv,"2376.68",w564,"5498.87",985

please help me on this

Thanks in advance..

Moderator's Comments:
Mod Comment Use code tags please, see PM.

Last edited by zaxxon; 12-02-2011 at 10:33 AM.. Reason: code tags
# 2  
Old 12-02-2011
Try:
Code:
awk -F\" -vOFS="\"" '{for (i=2;i<=NF;i+=2) sub(",","",$i)}1' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 12-04-2011
Alternatively:
Code:
awk 'NR%2-1{gsub(/,/,x)}1' RS=\" ORS=\" infile

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 12-05-2011
Now, the above two commands working fine

Thank you ...
# 5  
Old 12-05-2011
Gani85 , nice question
# 6  
Old 12-05-2011
Hi friends...

This comand is working fine, but facing an issue while having the input like below:-
Code:
abc,ttt,"""24,123,89.98",yyu,opp
vvv,"1,423,76.68",w564,"54,98.87",985
abc,ttt,"""67,123,89.98",yyu,opp
vvv,"88,523,76.68",w564,"54,98.87",985

If i am having two or three commas inside the double quote, i am not geting the desired output(the output will be zero commas inside the double quote). This command is removing one comma at a time and i am not sure how many commas will be inside my input file. it may be one,two,three...

Please help me on this.

Thanks in advance..

Moderator's Comments:
Mod Comment Please use code tags!

Last edited by zaxxon; 12-05-2011 at 09:08 AM.. Reason: code tags, see PM
# 7  
Old 12-05-2011
Hi, did you try my solution? I anticipated multiple commas and therefore I used gsub instead of sub (hence the hightlighting of the letter g)..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. What is on Your Mind?

Merry Xmas (special present inside)

A Merry Xmas to all of you. And, as a special present to vbe (he knows why) a little exercise: #! /bin/ksh pPrintSnow () { typeset -i iLen=$1 while (( iLen )) ; do if ! (( RANDOM % 31 )) ; then printf "%1s" "." else printf "%1s" " " fi ((... (0 Replies)
Discussion started by: bakunin
0 Replies

3. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

4. Shell Programming and Scripting

Replacing Comma delimiter coming inside the data.

Hello, I am having flat file (Comma Delimiter) and the data in the file is as given below. EMPNO, ENAME, DESIGNATION, SALARY 10979, Arun Kumar, Cosultant, 35000 13555, Bidhu Shekar, Senior Consultant, 45000 15000, Kiran, Kumar, Senior, Consultant, 40000 If... (9 Replies)
Discussion started by: arunvasu2
9 Replies

5. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

6. Shell Programming and Scripting

Removal of comma(,) present inbetween double quotes(" ")

Hi Experts, I have a file with some of the records contain double quotes. If I found a double quote(") in any particular record , I need to look for the next double quote in that particular record and in between these quotes, if any comma(,) is there I need to replace with Tilde (~) in the same... (12 Replies)
Discussion started by: vsairam
12 Replies

7. Shell Programming and Scripting

To Replace comma with Pipe inside double quotes

Hi, I have a requirement to replace the comma's inside the double quotes. The comma's inside the double quotes will get changed dynamically. Input Record: "Washington, DC,Prabhu,aju",New York Output Record: "Washington| DC|Prabhu|aju",New York I tried with the below command but it... (3 Replies)
Discussion started by: prabhutkl
3 Replies

8. Shell Programming and Scripting

sed removing comma inside double quotes

I have a csv file with lines like the followings 123456,"ABC CO., LTD","XXX" 789012,"DEF LIMITED", "XXX" before I bcp this file to database, the comma in "CO.," need to be removed first. My script is cat <filename> | sed 's/"CO.,"/"CO."/g' but it doesn't work. Can anyone here able to... (2 Replies)
Discussion started by: joanneho
2 Replies

9. Shell Programming and Scripting

To find the count of records from tables present inside a file.

hi gurus, I am having a file containing a list of tables.i want to find the count of records inside thes tables. for this i have to connect into database and i have to put the count for all the tables inside another file i used the following loop once all the tablenames are inside the file. ... (1 Reply)
Discussion started by: navojit dutta
1 Replies

10. Shell Programming and Scripting

remove files with 0 size, space and double qoute

os=hpux11 shell=ksh some jokers had written thousands of empty files into my $HOME. and the files are named inconsistently that some of them include space and double qoutes. all those files are of 0 size (when i did ls -al it told me so). the naming paterns are like e.g of ls -al output: ... (3 Replies)
Discussion started by: nongrad
3 Replies
Login or Register to Ask a Question