[Tutor] Saving Files for Spreadsheet Exporting

BELSEY, Dylan dylan.belsey@baesystems.com
Thu, 15 Aug 2002 10:45:48 +0930


Hi Alan,
	I'm quite sure that you have considered this but the simplistic way
is to loop through the list and append a tab "\t" or a ";" etc to the end of
each string and write to a file.  In pseudo code:

open file for writing
for each element in outerlist
	for each element in the innnerlist
		obtain the string
		append delimiting character
		write to file

	write newline to a file
close the file

	I would probably consider this to be slow if speed was an issue for
you, as the lists have to be iterated through and file I/O may also consume
some time. Unfortunately I don't know Python that well to suggest any
inbuilt Python to aid the process.
	As far as implementing the above pseudo code, I would begin
searching the docs for file reading and writing etc and string operations (I
don't mean the 'string' module as such).
	HTH
		Dylan

-----Original Message-----
From: Alan Colburn [mailto:aicolburn@yahoo.com]
Sent: Thursday, 15 August 2002 10:30
To: Python Tutor List
Subject: [Tutor] Saving Files for Spreadsheet Exporting


Two quick questions today:

1) I'd like to save a file, with a list of lists, in a format that could be
read directly into a spreadsheet. Each list would represent a different row,
and each list element a different column. How would I go about doing this?
(List elements are strings.)

2) In the interest of "teaching a man to fish" (rather than "giving him a
fish"), how would you go about searching the Python documentation to find an
answer to this question? ... That's where I started, but I wasn't successful
:-)

Thanks, as always! -- Al


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor