more newbie list questions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

more newbie list questions

From: googleboy <mynews44@yahoo.com>
Date: Wed Jul 13 2005 - 23:12:40 CEST

Hi there.

I am doing a bunch of processing over a list of lists, and am
interested in doing several things taht don't seem to be working for me
just at the moment.

I have a list of books with several fields (Title, Author1, Author2,
Publisher, ISBN) in a csv.

I have a cell.txt file that looks like this:

++
The title is %title%. <br><br>
The author is %author1% %author2% <br><br>
The Publisher is %publisher1% %publisher2% <br><br>
The ISBN is %ISBN% <br><br>
++

I know how to do something like sAuth = re.sub('%author1%', author1,
sTemplate), but I can't figure out to populate variables within python
from the list of fields.

The second thing I am trying to figure out is how to add a field (or
populate an empty field) called filename with the value of ISBN +
'.txt', though I hope this becomes pretty self evident after someone
helps me with the above.

The last thing that is vexing me at the moment is something I am not
sure if it is possible. Once I have populated this filename field, I
will want to try to do something like:

for book in all_books
    open(r'd:\path\to\files\%filename%', 'a')
    some_function

Where I replace %filename% with the value of the filename field for
each book. Is it possible to do some sort of search and replace like
that over a command within python?

Or is there another way entirely different to accomplish such a task,
like maybe assigning the path/filename to a variable... ?

TIA!

Googleboy
Received on Thu Sep 29 16:56:27 2005