From: Albert Wagner Date: 2001-11-05T05:40:12+09:00 Subject: [ruby-talk:24352] Re: Joys of eval Hi, Bill. Yes, I have been using your regexp with no problems. It just had finally noticed that Ruby was parsing the contents of an array almost exactly like a CSV file. So I started playing with eval. I still haven't tried the regexp on a significant sample of files. I'll get back to you when I get into trouble. I still think it is a cool regexp. Thanks again. On Sunday 04 November 2001 02:25 pm, you wrote: > Hi Albert, > > > Just wondering if the regexp version had indeed worked out OK, or have > you encountered data since then it couldn't handle? > > (The one in [ruby-talk:22534] didn't handle embedded quotes for instance; > the one in [ruby-talk:22537] can handle embedded quotes, but, I suspect, > probably not the way something like MSAccess might output them, given > what was learned about Excel's seemingly strange way of quoting in > [ruby-talk:22541] . . . :-) > > By the way I recently discovered that the flatten!.compact! used in > the code referenced above should be changed to flatten.compact without > the exclamation points. Or at least the 'flatten' at any rate - because > the 'flatten!' version "returns nil if no modifications were made." > (Pickaxe, Ch. 22) Whereas, we need the resulting array always, modified > or not, to pass on to 'compact'. > > If you have need of handling embedded quotes in the CSV parsing, perhaps > you could post some examples here of the quoting syntax MSAccess uses to > encode the data? I'm pretty sure the regexp can be adapted to handle it. > > For instance, Excel had taken: > > +-----+---------------+ > > |blerb|"hey,you","man,| > > +-----+---------------+ > > And had written (to the .csv file): > > blerb,"""hey,you"",""man," > > . . . But, odd-looking or not, this appears well within the realm of > regexps to handle. :-) > > > Regards, > > Bill