473,804 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parse CSV headers & dynamically generate SQL table?

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
2 2982
ja**********@ya hoo.com (Jonathan Epstein) wrote in message news:<27******* *************** ****@posting.go ogle.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
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**********@r ediffmail.com> wrote in message
news:ab******** *************** ***@posting.goo gle.com...
ja**********@ya hoo.com (Jonathan Epstein) wrote in message

news:<27******* *************** ****@posting.go ogle.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2451
by: None | last post by:
Hello, I am a total newbie to PHP and programming in general. I am playing around with a PHP / MySQL shopping cart script which I found at http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_cart.html. When I try to start a session or create a cookie, I get the following errors. Warning: Cannot send session cache limiter - headers already sent (output started at /wrapper_head2.php:27) in /cart.php on line 13 Warning: Cannot...
5
6793
by: ccjunk | last post by:
This may be a simple one but I have been working on it without joy for a couple of days now. Reading books and searching these groups hasn't helped yet either. I am trying to create a table dynamically with column headers based on the value of certain nodes and the rows populated ewith the values of certain child nodes of the same parent. My xml is something like this:
4
7280
by: El Diablo | last post by:
Hi there, I'm trying dynamically generate extra rows in a table. So far this achieves this task within the tHead segment: theTable.tHead.appendChild(document.createElement('TR')) ....but this only gives me table rows with no table data cells. So I would like to know if it's possible to create several <TH> within the tHead row using this method?
7
7701
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official Impact Summary</td> </tr> <tr> <td colspan=2></td>
2
1641
by: grawsha2000 | last post by:
Hello, How can I add a table to asp.net page dynamically with Code Behind style. I still can't find a way of doing it. This really causes me a big problem when I deal with records from database as I need to construct the table dynamically.
10
1943
by: John Wilson | last post by:
My app produces some long datatables to display in a grid. So I put them in a div so users can scroll. But the grid headers scroll out of view. I would like to stop them doing this. Can I fix them in place at the top of the div? -- John Wilson
0
2263
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
5
6766
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
25
2876
by: URmusicandvideo | last post by:
I have just finshed my first php code and posted it online and I am getting a Parse error: syntax error, unexpected T_VARIABLE in /home/hydeands/public_html/phpmail.php on line 45 But when I look at it it looks ok. . I am just creating a php for a online form to direct the email. Here is the code. <?php $emailsubject = 'Judgement Recovery Application' ; $web = 'mwcinvestigation@example.net' ;
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.