[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: FasterCSV problem

James Gray

8/28/2006 9:25:00 PM

On Aug 28, 2006, at 3:40 PM, Mark Van Holstyn wrote:

> Is there any way to make the faster CSV library parse this line?
>
>
> 20 6" Multibrand Pricer Insert 2 4
>
> I know i can use the :col_sep options to change the column
> separator to a
> tab, but it fails to parse this because of an unclosed quoted
> field. It
> seems like there should be an option to say that the fields are not
> quoted.

Well, if quotes aren't quoted it's not CVS and all the parser you
really need is:

line.split("\t")

right? ;)

FasterCSV uses a very strict parser, so no it won't allow this. Sorry.

James Edward Gray II

2 Answers

James Gray

8/28/2006 10:31:00 PM

0

On Aug 28, 2006, at 5:22 PM, Mark Van Holstyn wrote:

> I did end up cleaning the row myself. I just wondered if I was
> missing the
> option somewhere. The only reason I ask is because Excel/OOCalc
> allow you to
> say whether or not fields are surrounded by "'s. It would be a nice
> option.

I guess I'm dense today...

FasterCSV is for parsing CSV. Without quoting, we are not talking
about CSV.

Can you please explain how `fields = line.split("\t")` fails you?

If there's a real need for this, I'll consider it. But right now I
would implement it as the above and I hope that's not what your
asking for. ;)

James Edward Gray II

James Gray

8/28/2006 10:58:00 PM

0

On Aug 28, 2006, at 5:42 PM, Mark Van Holstyn wrote:

> If this is something you dont thinks should be in the CSV library,
> because
> is it not actually "official" csv, then that is fine.

Well, it's more that I don't see what I can give you that split()
doesn't. Hard for me to improve on that, you know? ;)

> I look at that file as
> being "almost" CSV (with the exception of putting "'s around fields).

In proper CSV the 6" field would really be:

"6"""

It's pretty different. Without the quotes it's illegal to use \t,
\r, and \n in fields (I assume). There's just really nothing there
you need a parser for, in my opinion.

James Edward Gray II