Re: [Tutor] Alternative File I/O for Tuples
by Kent Johnson other posts by this author
Jun 26 2005 6:25AM messages near this date
[Tutor] Alternative File I/O for Tuples
|
Re: [Tutor] Alternative File I/O for Tuples
Don Parris wrote:
> When I pickle a SQL result into a file (ASCII mode), it lays out the data in
> an interesting format.
pickle format is not intended for pretty-printing or readability for that matter. You have t
o write the file yourself in the format you want.
> When I send it to the printer, I'd like to see it
> arranged more like it is on the console screen - in tabbed columns. None of
> the tutorial type stuff I've seen even mentions printing files, or accessing
> the files you create in a Python program. I did manage to find an example
> of a print function.
It sounds like you want to write a file for later printing. Writing files should be covered
in any Python tutorial; the standard tutorial talks about it here:
http://docs.python.org/tut/node9.html#SECTION009200000000000000000
Danny has given you some hints about how to do the formatting. This recipe has a very comple
te solution for formatting tables. You could easily change the example to print to a file:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267662
Kent
>
> Here is some sample data from the resulting file:
>
> ((S'Everybody'
> S'Anonymous'
> Nt(S'James'
> S'Austin'
> S'704-111-1234'
> t(S'Janet'
> S'Austin'
> S'704-111-1234'
>
> I would like to see something more like when the file is printed:
>
> Austin James 704-111-1234
> Austin Janet 704-111-1234
> etc.
>
> Is this a simple task, or am I jumping into deep water? :)
>
> Don
_______________________________________________
Tutor maillist - Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Don Parris
Kent Johnson
Danny Yoo
Danny Yoo
|