[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: text processing library

DDENNISON

4/17/2007 5:23:00 PM

Hi,

Since you are describing a lot of what I do (but not in Ruby), I thought I
might point you here for some ideas: http://www.unidex.com/ov...

Essentially, that link describes a flat-file parser that reads a XML
definition of the layout. You might want to use that and model your own
schema to accomplish something similar in Ruby.

Best Regards,
Dan




"Stephen Smith"
<4fires@gmail.com
> To
ruby-talk@ruby-lang.org (ruby-talk
04/17/2007 11:12 ML)
AM cc

Subject
Please respond to Re: text processing library
ruby-talk@ruby-la
ng.org








@Botp, That's right up my alley... Here's where I'm headed. Since CSV file
structure is a bit like vanilla icecream, I'd like to provide a file
structure with more complexity or "flavor" as an input, along with some
CSV'd data. That way I can read in the structure and the data separately
and
get my data out in the format I want. My inspiration is deBabelizer, but
also now simply some kind of String#pack.

On 4/17/07, Peña, Botp <botp@delmonte-phil.com> wrote:
>
> From: Stephen Smith [mailto:4fires@gmail.com] :
> # go from csv to
> # batch file automagically, and just writing a one-off for this one file
> # format seems like a total waste of time.
> # There are a bizillion of these formats out there, and I have
> # to imagine
> # spooning csv files into yet another format is pretty common.
> # I'm wondering
> # if Ruby already has a batch file library, something like
> # text-format.rb only
> # more useful?
>
> just in case you'd want to start anew, try getting some ideas fr
> 1. http://www.devsource.com/article2/0,1895,1928...
> 2. http://fastercsv.ruby...
>
> kind regards -botp
>
>
>


This message and any attachments contain information from Union Pacific which may be confidential and/or privileged.
If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited by law. If you receive this message in error, please contact the sender immediately and delete the message and any attachments.

1 Answer

James Gray

4/18/2007 3:08:00 AM

0

On Apr 17, 2007, at 9:31 PM, Stephen Smith wrote:

> @James, Right on. I think you're correct - FasterCSV should handle
> the CSV
> reading no problem. I think my first edition might handle writing
> to a flat
> file based on an XML schema. I'm going to try to think about
> generalization
> from the beginning, and see if that keeps my code easier to
> maintain and
> use. When you wrote FasterCSV, how did you bake in the formatting
> rules? Did
> you write an XML schema or something similar based on the CSV RFC?

FasterCSV was born from a discussion on Ruby Core about how we might
speed up the CSV library. I provided some information out of the
book Mastering Regular Expression, which claimed to have a single
expression for parsing the format.

Some edge case that the expression didn't handle where raised, I
fixed those, and that's pretty much FasterCSV's parser to this day.
It's not too glamorous I guess, but I like how it shows what we can
do when we work together.

James Edward Gray II