Replace number with double quotes from csv file using vi editor

206 views Asked by At

I have a CSV file containing the data like below -

"Rank","Domain","Open Page Rank"
"1","fonts.googleapis.com","10.00"
"2","facebook.com","10.00"
"3","twitter.com","10.00"
"4","google.com","10.00"
"5","youtube.com","10.00"
"6","instagram.com","10.00"
"7","s.w.org","10.00"
"8","ajax.googleapis.com","10.00"
"9","linkedin.com","10.00"

How can I remove double quotes from all numbers here using vi editor or similar effect?

Thanks

1

There are 1 answers

2
Z4-tier On BEST ANSWER

you could use a regex search and replace:

%s/"\(\d\+\(\.\d\+\)\?\)"/\1/g

"on every line in the file, find...
all strings that start with a double quote...
followed by one or more digits...
optionally, followed by a period, which is followed by one or more digits...
followed by a double quote...
replace the string with the outer capture group...
and do it everywhere it appears on the line. "