Jump to content

Archived

This topic is now archived and is closed to further replies.

Jimbo_17

CSV files

Recommended Posts

Is there any way to load a CSV file into anything like the mysql functions in PHP. For example, PERL can open a CSV file and run queries on it as though it were an SQL database.

Share this post


Link to post
Share on other sites
I've done this before... fopen() fgets(), then explode() by comma.

No sorting, no joining, no relations, no indexing, and rudimentary searching. Depending on the size of the file, it might even be snail slow.

Better idea: Write a converter to put your CSV into a mysql database. I have several of these running through cron. They download the CSV file via FTP, parse it, and dump it into a mysql database -- every day. MySQL loves doing advanced searches and sorts lightning fast.

Share this post


Link to post
Share on other sites
Instead of
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]fopen() fgets(), then explode() by comma.[/quote]
you really should look at the [a href=\"http://www.php.net/fgetcsv\" target=\"_blank\"]fgetcsv()[/a] function, since it knows how to handle commas inside a quoted string.

Ken

Share this post


Link to post
Share on other sites
Might look at these...

[a href=\"http://www.c-worker.ch/txtdbapi/index_eng.php\" target=\"_blank\"]http://www.c-worker.ch/txtdbapi/index_eng.php[/a]

[a href=\"http://ffdb-php.cvs.sourceforge.net/ffdb-php/README?revision=1.6&view=markup\" target=\"_blank\"]http://ffdb-php.cvs.sourceforge.net/ffdb-p...1.6&view=markup[/a]



Lite...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.