By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,641 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,641 IT Pros & Developers. It's quick & easy.

parse CSV headers & dynamically generate SQL table?

P: n/a
I have a collection of CSV datasets which will all contain different
numbers of columns and different column headers. There will always be
a fixed number of such files and they have some common
characteristics, especially those with column names in common (e.g.,
at some point I will be performing some database joins based upon
similar column names).

Initially I would like to parse each CSV file and automatically create
a mySQL table containing fields corresponding to the CSV file headers.

In some subsequent web page(s) I will be performing some boolean
queries against this mySQL database, and will need to query the field
names on the fly so that I can create suitable drop-down lists for the
user to formulate her query.

I'm really a Perl programmer, but have a feeling that this will be
much easier in PHP.

Thanks in advance for any pointers.

Jonathan
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ja**********@yahoo.com (Jonathan Epstein) wrote in message news:<27**************************@posting.google. com>...
I have a collection of CSV datasets which will all contain different
numbers of columns and different column headers.


<snip>

Is it what you're looking for <http://in.php.net/fgetcsv> ?

--
http://www.sendmetoindia.com - Send Me to India!
Email: rrjanbiah-at-Y!com
Jul 17 '05 #2

P: n/a
Thanks, this helps with the parsing. The next step (and the more difficult
one) is to create the database on the fly.

But the web site you showed me also shows how to create databases and tables
using mysql_query() so I think that I'm more-or-less in business.

Refs for other PHP newbies:
http://in.php.net/manual/en/ref.mysql.php
http://in.php.net/manual/en/function...-create-db.php
(note deprecation of mysql_create_db() but instructions for use of CREATE
DATABASE are also provided)

Jonathan

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
ja**********@yahoo.com (Jonathan Epstein) wrote in message

news:<27**************************@posting.google. com>...
I have a collection of CSV datasets which will all contain different
numbers of columns and different column headers.


<snip>

Is it what you're looking for <http://in.php.net/fgetcsv> ?

--
http://www.sendmetoindia.com - Send Me to India!
Email: rrjanbiah-at-Y!com

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.