From: Albert Wagner Date: 2001-10-14T06:46:26+09:00 Subject: [ruby-talk:22497] Re: extracting from delimited text files Thank you, Robert. I was unaware of both the csv module and the Ruby Cookbook. I got this far with String#split but couldn't get rid of the quote in element 0 and how to force empty strings for the trailing commas: irb(main):048:0> x "\"aaa\",,\"ccc\",,,\"fff\",,," irb(main):049:0> y = x.split(/\"\s*,\s*\"|\"\s*,|\s*,\s*\"|\s*,|\s*\z/) ["\"aaa", "", "ccc", "", "", "fff" On Saturday 13 October 2001 04:05 pm, you wrote: > Check out http://ruby.yi.org/raa/en/all.html > there is a module called 'csv'. > You can also look at Ruby's Cookbook at > http://www.rubycookbook.org/recipes.rb > for help > > --- Albert Wagner wrote: > > What is the simplist way to extract fields from > > standard quoted, comma > > delimited text files such as are commonly exported > > from database programs? > > Are there already classes/modules written? Or is > > this normally just done > > with the standard String methods? I don't yet know > > enough about regular > > expressions to make String.split do what I want. > > Any help is appreciated. > > Thanks ahead. > > > > Albert