[dev] Data_CSV Queries

Jan Schneider jan@horde.org
Tue, 30 Jul 2002 15:54:46 +0200


Zitat von Michael Cochrane <mike@graftonhall.co.nz>:

> The Data_CSV class has a few problems and i was wondering if there were
> any
> prefered fixes....
> First problem is exporting strings that contain the deliminater... 
>  1. Should the deliminater just be striped (doesn't sound good)
>  2. Should the string be double quoted (seems to be common)
>  3. Should the deliminater be escaped in some way?

2.
 
> The second problem relates to Importing data.
> When multiline data is exported by Data_CSV it looks like this:
> 
> "Name", "Address"
> "Mike", "40 Seafield View Rd
> Grafton
> Auckland"
> 
> But the current import code stops when it gets to the end of the line,
> not the
> end of the quote. Should this be changed or should the export be changes
> to
> somehow escape or strip the newlines? 

I'm not sure. There is no standard for csv files and I don't know if there
is a best practice. But as \n isn't known by any os/language, I guess the
csv renderer should look after the linebreak if we are inside double quotes.
We currently use the php builtin csv parser, but perhaps the parser in pear
works better. Someone might want to find it out.
 
> FYI: I have a NAG import/export coming in about 5 mins...

Cool!

Jan.

--
http://www.horde.org - The Horde Project
http://www.ammma.de - discover your knowledge
http://www.tip4all.de - Deine private Tippgemeinschaft