luditus has asked for the wisdom of the Perl Monks concerning the following question:

Hi there, I want to include some data into my website which covers malaria and yellow feewer related to each country. On the WHO website are all the infos I need. Their webmaster told me that unfortunatelly there is no db behind that and everything gos with html files. But I am free to extract that data. Well, I did create a txt file which looks more or less like that:
ALGERIA Yellow fever: A yellow fever vaccination certificate is required from travellers over 1 year of age coming from infected areas. Malaria: Malaria risk is limited. One small focus (P. vivax) has been reported in Ihrir (Illizi Department), but this is isolated and access + is difficult. Recommended prophylaxis: none. AMERICAN SAMOA Capital: Pago Pago Altitude: 10 m Yellow fever: A yellow fever vaccination certificate is required from travellers over 1 year of age coming from infected areas.
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. somebody mentioned in a php group, that I should better look out at a perl site.Do u guys think this could be done??? Doing it by hand could take allllloooong loooooong while. I am open for any idea! Thanx a lot for any help Cheers, Andy

Replies are listed 'Best First'.
Re: extracting data out of a txt file
by grep (Monsignor) on Mar 06, 2002 at 21:07 UTC

    What you'll need to look at the DBI module and the MySql DBD Driver.

    You'll also need to look at open to open your text file and read it in.

    I'll leave the rest up to you and if you need any more help please feel free to ask it here with some code samples to help us out

    If you are interested you can look at some nodes pertaining to asking questions (so you can make sure you get the best answer possible):
  • turnstep's Home Node
  • On Asking for help
  • Before you post...
  • How to ReadTheFineManual


  • grep
    grep> cd /pub
    grep> more beer
Re: extracting data out of a txt file
by silent11 (Vicar) on Mar 06, 2002 at 21:06 UTC
    I'd first suggest getting some structure to your data. It looks like you have broken down what you have so far by country, is every country going to have the same data?
    i.e. for Algeria you have the definition of Yellow Fever, and for american samoa you have country stats.
    is there a comom theme between countries? Tell us some more and Im sure we can help.
    also, can you give us a link to this 'who' website?

    -Silent11