RE: [PEAR-DEV] [new] File_CSV class avaible
| From: | Brent Cook | Date: | Sun, 21 Jul 2002 07:07:40 +0000 |
| Subject: | RE: [PEAR-DEV] [new] File_CSV class avaible | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7812@lists.php.net to get a copy of this message | ||
> > I just want to announce that the new class File_CSV is avaible. As the
> > PS.- Someone liking to develop a CSV driver for PEAR DB?
> ;-)>
>
> I think I have the beginnings of one already. I just subscribed to this
> list today and found this message in the archive a couple of minutes
> ago. I was planning to lurk for a while before submitting a new driver
> for PEAR DB, but I guess I'll jump right in.
>
> I wrote a driver called querysim and it does just that, it simulates the
> resultset of a select query. It's based on the ColdFusion custom tag of
> the same name at www.halhelms.com. (I'm a longtime CF programmer
> teaching myself PHP these last few weeks. This is only my second piece
> of PHP code, so no laughing. :) ) It can read inline QuerySim text as
> well as external files, and because it has configureable delimiters, by
> default, it can also read simple CSVs. I haven't looked at File_CSV
> closly yet but it could replace my file reader and parser. My parser is
> just getting bigger and bigger to handle 'weird' cases, and one of the
> things on my to do list is to add quoted field support, which you have.
> Anyway, the more I thought about it, the more I thought the parser
> should live in it's own driver. And here there has been a class all
> along that just needs a wrapper.
>
> I've also had grand visions of adding an SQL parser and
> being able to read and write to CSV style files.
>
> I am interested in working on this.
>
> -Alan
Dear Alan,
You should check out the DBA package already in PEAR for an attempt at
creating a local file-based database system. It supports selects in a
different way than your system; it uses the PHP parser to do a lot of the
work by converting queries to PHP and calling eval(). So, a select query
might look like:
$results = $db->select('fruits', '(type != avacado) && (price >
0.23)');
on a table containing fruit information.
It also supports using either PHP's built-in DBA functions or using a
simple system of linear indexes with a data file (random-access CSV,
essentially, backward compatible with a plain CSV parser). It also does
projects, sorts, joins, etc. A SQL parser is about 10% complete and
supports CREATE TABLE and INSERT so far, with an eventual goal of actually
having a driver in PEAR DB (depending on how practical it ends up being).
Check it out here, CVS, and back issues of pear weekly news:
http://pear.php.net/package-info.php?pacid=85
http://pear.php.net/weeklynews.php
By the way, where is the code for the PHP squerySim? I was only able to
find something calling itself a fusebox tag, which was written in some XML
language.
- Brent