Help with language, dev tool selection

Discussion in 'Python' started by vasilijepetkovic@yahoo.com, Oct 21, 2005.

  1. Guest

    I have a problem that I have to solve programmatically and since HTML
    is pretty much the only code I have been exposed to I need an advice on
    how to develop the programmatic solution to the problem I have.

    In the nutshell, it'd be great if you can give me guidance in terms
    of:

    1) What programming language to use
    2) What development tools to use
    3) Tips on how to code the solution

    So, here is my challenge:

    I have a flat text file, 30000 records, each record has two columns,
    the columns are tab separated.

    The file looks like this (approximately)

    Sarajevo 431104-133111
    Mostar 441242-133421
    Zagreb 432322-134423


    The first value is a name of a town, and the second value represent
    longitude-latitude in degrees, minutes and seconds.

    For each record I have to create an html file that will be named as the
    name of the town (i.e. Sarajevo.html). The content of the file will be
    rather simple; in the first row it will contain the header (i.e.
    "This page displays longitude-latitude information") - The second
    row will have the following word: "Grad" - and the third row will
    contain the name of the city and the fourth row will have the
    longitude-latitude info.

    The program also needs to prompt me (before it starts spitting the html
    pages) and ask what test should be entered in line one (I would than
    manually enter "This page displays longitude-latitude information")
    and it also need to prompt me about the text that should be entered in
    line two (I'd go and manually enter "grad").

    I'd greatly appreciate any coment and/or guidance.


    Best,

    Vasilije Petkovic Vasa
     
    , Oct 21, 2005
    #1
    1. Advertising

  2. Guest

    Further clarification:

    The pages will have to be pure static html pages (so no datasource will
    be driving generation of the pages).

    Therefore, I'd have to create
    30,000 files.

    It's my understanding that almost every host should be
    able to serve a simple and static html code.

    Best,
    Vasa
     
    , Oct 21, 2005
    #2
    1. Advertising

  3. wrote:

    > 1) What programming language to use


    This is trivial task, whatever language you choose, will do it.
    Python too, and its also simple and popular, so i can recommend it.

    > 2) What development tools to use


    You don't need nothing beyond python interpreter.

    > 3) Tips on how to code the solution


    Read the python tutorial (www.python.org) and thats probably all you need to
    know.

    > For each record I have to create an html file that will be named as the
    > name of the town (i.e. Sarajevo.html). The content of the file will be
    > rather simple; in the first row it will contain the header (i.e.
    > "This page displays longitude-latitude information") - The second
    > row will have the following word: "Grad" - and the third row will
    > contain the name of the city and the fourth row will have the
    > longitude-latitude info.


    Its maybe 10-20 lines of trivial code, so i suggest you to read python
    tutorial, unless its only do-it-once operation.

    Do you really need to create 30k files? this will take a lot of time
    (creating a file is time-consuming operation on creation, sending them to
    server too) and disk space greedy - even if file has 300 bytes, it may take
    4kb or more on disk, depending on filesystem and its settings.
    Perhaps collecting names starting with the same letter in single file will
    be enough.

    --
    Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
    www.fiedzia.prv.pl

    Ankh if you love Isis.
     
    Maciej Dziardziel, Oct 21, 2005
    #3
  4. Guest

    , Oct 21, 2005
    #4
  5. Larry Bates Guest

    1) Python can do this easily
    2) No tools required
    3) Don't do it the way you describe.

    Here's what I would do:

    Load the information that you have in the text file
    into a MySQL database (MySQL import has tab delimited
    as its default so it is easy) and write a few lines of
    PHP to serve up the HTML pages dynamically. I say PHP
    and MySQL because almost every Internet Service
    Provider installs those tools for free when you host a
    website. If you are self hosting, use Python to create
    the pages dynamically as they are required. Besides,
    it will take you almost as long to upload the 30000
    html pages to your webserver as to write this entire
    application.

    -Larry Bates


    wrote:
    > I have a problem that I have to solve programmatically and since HTML
    > is pretty much the only code I have been exposed to I need an advice on
    > how to develop the programmatic solution to the problem I have.
    >
    > In the nutshell, it'd be great if you can give me guidance in terms
    > of:
    >
    > 1) What programming language to use
    > 2) What development tools to use
    > 3) Tips on how to code the solution
    >
    > So, here is my challenge:
    >
    > I have a flat text file, 30000 records, each record has two columns,
    > the columns are tab separated.
    >
    > The file looks like this (approximately)
    >
    > Sarajevo 431104-133111
    > Mostar 441242-133421
    > Zagreb 432322-134423
    >
    >
    > The first value is a name of a town, and the second value represent
    > longitude-latitude in degrees, minutes and seconds.
    >
    > For each record I have to create an html file that will be named as the
    > name of the town (i.e. Sarajevo.html). The content of the file will be
    > rather simple; in the first row it will contain the header (i.e.
    > "This page displays longitude-latitude information") - The second
    > row will have the following word: "Grad" - and the third row will
    > contain the name of the city and the fourth row will have the
    > longitude-latitude info.
    >
    > The program also needs to prompt me (before it starts spitting the html
    > pages) and ask what test should be entered in line one (I would than
    > manually enter "This page displays longitude-latitude information")
    > and it also need to prompt me about the text that should be entered in
    > line two (I'd go and manually enter "grad").
    >
    > I'd greatly appreciate any coment and/or guidance.
    >
    >
    > Best,
    >
    > Vasilije Petkovic Vasa
    >
     
    Larry Bates, Oct 21, 2005
    #5
  6. wrote:

    > I have a flat text file, 30000 records, each record has two columns,
    > the columns are tab separated.
    >
    > The file looks like this (approximately)
    >
    > Sarajevo 431104-133111


    (when did they move sarajevo to italy?)

    > Mostar 441242-133421
    > Zagreb 432322-134423


    here's a straightforward Python solution:

    HEADER = "This page displays longitude-latitude information"
    SUBHEADER = "Grad"

    for line in open("datafile.txt"):

    town, latlong = line.split()
    lat, long = latlong.split("-")

    f = open(town + ".html", "w")
    f.write(HEADER + "\n")
    f.write(SUBHEADER + "\n")
    f.write(town + "\n")
    f.write(long + " " + lat + "\n")
    f.close()

    # end

    tweak as necessary. see the Python tutorial for help:

    http://docs.python.org/tut/tut.html

    </F>
     
    Fredrik Lundh, Oct 22, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger
    Replies:
    2
    Views:
    16,533
    Christian Kaufhold
    Jan 7, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,478
    Andrew Crowe
    Sep 13, 2004
  3. Ron Peterson

    /dev/urandom vs. /dev/random

    Ron Peterson, Jan 7, 2005, in forum: C Programming
    Replies:
    21
    Views:
    1,544
    Keith Thompson
    Jan 13, 2005
  4. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    272
    curiousity
    Nov 21, 2003
  5. AC
    Replies:
    0
    Views:
    165
Loading...

Share This Page