hi,
i’m searching for a way to remove inline double quotes in ruby,
especially in a csv file.
sth like “blabla “title” blbl”;“bla bla” should become
“blabla ‘title’ blbl”;“bla bla”
thanks in advance
johnny
hi,
i’m searching for a way to remove inline double quotes in ruby,
especially in a csv file.
sth like “blabla “title” blbl”;“bla bla” should become
“blabla ‘title’ blbl”;“bla bla”
thanks in advance
johnny
John D. wrote:
hi,
i’m searching for a way to remove inline double quotes in ruby,
especially in a csv file.sth like “blabla “title” blbl”;“bla bla” should become
“blabla ‘title’ blbl”;“bla bla”thanks in advance
johnny
Your csv is malformed if it has such quotes, so there is no standard way
to remove them. You’ll have to use some regular expression, for example
if all the columns in your file are quoted, and t is a line from your
file, try this:
t.split(/^"|";"|"$/)[1…-1].map{|e| “”#{e.gsub(/"/,"’")}""}.join(";")
Probably not the easiest method, but certainly a one-liner.
TPR.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs