[Tutor] Saving and loading data to/from files
Michael P. Reilly
arcege@speakeasy.net
Sun, 3 Jun 2001 11:12:04 -0400 (EDT)
Daryl G wrote
> The %s doesn't quite work right. If a name is shorter than another, then the
> positions wont be right in my simple table. I guess I have to see if that
> center() method will work for me.
You need to put the width/length specifies in (just like with C).
> example
> LastName FirstName Phone#
> Stephanopolis George 900-856-2992
> Jo Mary 800-328-6387
> is what I end up getting.
For this, the formatting string would be:
fmt = '''%(L_Name)-15.15s %(F_Name)-15.15s %(PH_num)s'''
Last name ("(L_Name)"), left justified ("-"), 15 characters wide (max
and min, "15.15") string ("s"); same for first name; the phone number
is an unrestricted string.
> Computer Spreadsheet Vomitus. I love that. :)
Actually, CSV means "comma-separated values" and it is more complicated
than just splitting on a comma: if the data has a comma, then the value
is quoted with double-quotes, but what if the value has a double-quote?
It is also only a textual format, not a data retrieval system; it is
one means used to transfer data between database systems. Usually the
first line is the field names. If you're interested, look for "ASV"
in the Vaults of Parnassus <URL: http://www.vex.net/parnassus/>.
-Arcege
--
+----------------------------------+-----------------------------------+
| Michael P. Reilly | arcege@speakeasy.net |