Books Database

Steve Holden sholden at
Fri Mar 7 13:58:31 CET 2003

"Dennis Lee Bieber" <wlfraed at> wrote ...
> Eliran Gonen fed this fish to the penguins on Thursday 06 March 2003
> 05:23 am:
> >
> > BTW what do you think is the best way to modify any of those fields
> > (in the format of name|author|year) in the future ? put the data in
> > a temporary variables modify them, delete the existing line and write
> > the line again ?
> >
> > This is because I want to add a "Loaner" criteria.
> >
>         If using a simple, character delimited, text file, you can't just
> "write the line again" because the length of the line may vary. You'd
> have to somehow mark the old line inactive (matching the exact width,
> or adding a first character for active/inactive flag) and then writing
> a new line at the end of the file. Eventually you'll want to run a
> compression routine which copies only the active lines to a new file,
> delete the old, rename the new (or for safety, rename the old first,
> then copy to the new using the original name).

All of which is probably Dennis' way of saying "it's much easier to rewrite
the whole file each time".

Any modern computer should have enough memory to keep your whole
bibliography as Python data inside a running program, and you will find this
*much* easier than adopting complicated file layouts to compensate for
differing line lengths on update.

some-thing-are-too-easy-to-throw-away-ly y'rs  - steve
Steve Holden                        
Python Web Programming       
Register for PyCon now!  

More information about the Python-list mailing list