Re: [new] File_CSV class avaible
| From: | Brent Cook | Date: | Mon, 15 Apr 2002 20:19:17 +0000 |
| Subject: | Re: [new] File_CSV class avaible | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-5535@lists.php.net to get a copy of this message | ||
> Hi,
>
> I just want to announce that the new class File_CSV is avaible. As the
> name suggests this class is for handling CSV files. The CSV (Comma
> Separated Values) is a common format for exporting/importing data in a
> simple way (well sometimes not so simple). Those files looks like:
DAMN! You beat me to it. I have a CSV class that reimplements all of the
PHP dbm functions too. I can't wait to see what your approach was!
Format discovery! I'm so excited! Multiline data is also tres cool!
> File_CSV vs fgetcsv():
>
> I've implemented two different algoritms for parsing the data. One
> simple and fast and another more complex and slow. Depending on the
> format of the file and the type of line read, the class will
> automatically switch between them. So, in a simple CSV file with no
> things like quote or multine fields the speed difference between fgetcsv
> and the class is almost null (plus the fact that the class will properly
> handle quoted data, multiline data or errors if there is any).
>
> PS.- Someone liking to develop a CSV driver for PEAR DB? ;-)
I have a semi-relational database that uses CSV files (it still needs join
and a more featureful select) The reason I can call it semi-relational is
because I can simulate a join by creating two tables and use
array_intersect() on two select results. It doesn't support the ACID
properties because table-locking is broken, but hey!
You can browse last-month's PHPDoc for the database class here - it's
called fdb: http://ozma.union.utexas.edu/~txunion/test/doc/test1/
I use it for apps like this events calendar:
http://www.utexas.edu/student/txunion/calendar/
and a catalog:
http://www.utexas.edu/student/txunion/ae/iclass/courses/
It seems to handle around 800 records pretty well, though I'm working on a
system that works well with a few thousand records called rdb (a real
relational database manager!) It even supports table locking (though row
locking is way too much trouble without shared memory). Slap in a SQL
parser, and viola!
- Brent