Jimbo_17 Posted June 23, 2006 Share Posted June 23, 2006 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. Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted June 23, 2006 Share Posted June 23, 2006 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. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 23, 2006 Share Posted June 23, 2006 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 Quote Link to comment Share on other sites More sharing options...
litebearer Posted June 23, 2006 Share Posted June 23, 2006 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.