[Tutor] Breaking string at commas

Shawhan, Douglas (GEAE, GECC) douglas.shawhan@ae.ge.com
Mon, 12 Mar 2001 12:29:35 -0500


I am trying to write a script that will take comma seperated text from a
file, break the strings into seperate units at the linefeeds then seperate
the comma seperated text into strings, insert html formatting then output
the whole shebang into an html file. I have figured out how to read the info
from the flat files and squirt them to html with formatting (do what you
can, if it's all that you can! :-).

---------begin ugly script---------------
f=open('/windows/desktop/shuffles/hippie.db','r')
grunty=f.read()
f=open('/windows/desktop/shuffles/whofrom.db','r')
whofrom=f.read()
f=open('/windows/desktop/shuffles/whofrom.db','r')
whoto=f.read()
f=open('punker.html','w')
f.write('<html><h1><b>MOVES/INSTALLS</b></h1><body bgcolor=white><font
face=\"arial,helvetica\" size=\"2\"><table width=580><tr><td
bgcolor=black>&nbsp;&nbsp;</td><tr><td>'+`grunty`+'</td><tr><td
bgcolor=black>&nbsp;&nbsp;</td><tr><td>'+`whofrom`+'</td><tr><td
bgcolor=black>&nbsp;&nbsp;</td><tr><td>'+`whoto`+'</td></table></font></html
>')
f.close()
----------end ugly script--------------

Now the tricky part for me is: How can I first bust the files apart at the
line breaks, then search for the unique id in the resulting output? Tuples?


The other trick is: How am I going to bust apart those strings within the
chosen output to insert the formatting? 

Feel free to poke me in the eye or point me to an example in a manual (I
have the tutorial from the website and a copy of Lutz and Ascher's so-far
excellent "Learning Python")

Thanks!

d