Text parsing example code

Hi rubyists,

has anyone some code to parse data from a text file, like semicolon
seperated data for example?

I would love read it to see how you implement a text parser in the ruby way
to make my own the right way :slight_smile:

In my case I have to parse a CSV saved by Open Office. The fields that
contain strings are enclosed by double quotes…
The CSV Module from RAA fails with a IllegalFormat Exception…

thanks!
Dominik

Hi, Dominik

From: “Dominik Werder” dwerder@gmx.net
Sent: Wednesday, June 25, 2003 9:21 PM

has anyone some code to parse data from a text file, like semicolon
seperated data for example?

$ ruby18-preview3 -rcsv -e ‘p CSV.parse_line(%Q(“abc”;“def”), ?;)’
[“abc”, “def”]

CSV module should be able to parse SSV formatted text.

Regards,
// NaHi

Might be better to help debug the CSV module, as per Joel Spolsky’s
observation that old code accumulates corner cases, and when you start
from scratch you lose the benefit of that painful accumulation. If the
RAA module has test suite, a few lines from your OO file might make a
valuable addition to it.

martin

¡¡¡

Dominik Werder dwerder@gmx.net wrote:

I would love read it to see how you implement a text parser in the ruby way
to make my own the right way :slight_smile:

In my case I have to parse a CSV saved by Open Office. The fields that
contain strings are enclosed by double quotes…
The CSV Module from RAA fails with a IllegalFormat Exception…