From: Peter Vandenabeele Date: 2012-01-10T08:44:26+09:00 Subject: Re: Stripping double quotes --bcaec5196189636df304b620fa0a Content-Type: text/plain; charset=UTF-8 On Mon, Jan 9, 2012 at 11:31 PM, Mickey Vogel wrote: > Hi, > > I have the attached file, but my issue is that the file I am parsing, is > in this format: > > "45hc43j","sdfsdf","","Dead","sdfdsf ","sgfsdf","","sdfg","null","", > > That is why I escape quotes in the script. How do I get an output that > doesn't have double quotes? I tried using gsub but it was of no use. > > Also, the data snippet above is a csv file...but if you were to output > it to command line and text after running the script, it returns those > elements as quotes as seen above. > > Any help will be appreciated. > Since you are really trying to open a CSV file ... use the existing CSV library http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html There are other cases that you might miss (e.g. newlines inside a "cell" are allowed (e.g. a return inside a cell in Excell/OpenOffice is possible) and may trip you). Probably there are more corner cases that are non-trivial in the beginning. HTH, Peter > > Mick > > Attachments: > http://www.ruby-forum.com/attachment/6893/parseLICDB.rb > > > -- > Posted via http://www.ruby-forum.com/. > > -- Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com gsm: +32-478-27.40.69 e-mail: peter@vandenabeele.com --bcaec5196189636df304b620fa0a--