On Wednesday, March 6, 2002, at 01:49  PM, Andy wrote:

> I want to include some data into my website which covers malaria and 
> yellow
> feewer related to each country.

To each his own, I suppose...

> Now I have a table in a MySQL db naming all those countries. The goal 
> is to
> extract the Yellow fever and Malaria line and put it into a mysql table
> related to the countries.
> I saw that PHP has some good functions on text, but do u guys think this
> could be done??? Doing it by hand could take allllloooong loooooong 
> while.

You've got the right idea to write a script that can enter the data into 
the database, but PHP may not be the best language to do it.  PHP is 
especially good at extracting data from text files or a database and 
then displaying it as HTML or any other format.  If you want to enter 
the data into the database, take a look at the mysqlimport utility 
(which comes with most MySQL distributions).
What I would do is write a Perl script that runs through the text file 
you made, and rearranges the data to be more acceptable to mysqlimport 
(I think mysqlimport requires its input in tab-delimited format).  You 
could either write this rearranged data to a new file and run 
mysqlimport on that, or in Unix you can pipe the output from the Perl 
script directly to mysqlimport.

The hard part is really going to be writing the Perl script, but I bet 
it won't be very hard.  It really depends on how the data in your text 
file is arranged -- i.e., is it consistent, or random?  I'm hoping that 
the actual file is a little more consistent than the examples you 
provided (i.e., not every entry has a "malaria" line or "yellow fever" 
line, and some entries have "altitudes" and "capitals" while others 

If it's consistent, a Perl guru could probably help you with little 
trouble -- check out www.perlmonks.org.  (Sorry, but I am far from a 
Perl guru.)



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to