[Tutor] WRITING XLS FROM OS.WALK()

Jed Smith jed at jedsmith.org
Fri Oct 8 23:02:18 CEST 2010


On Fri, Oct 8, 2010 at 3:34 PM, Susana Iraiis Delgado Rodriguez
<susana.delgado_s at utzmg.edu.mx> wrote:
> for i in allfiles:
>       print i
>       a.write(i)
>       a.write("\n")

Are you sure you want to write bare data to a file ending in .xls?
That might be confusing Excel, unless it has grown a sizable brain
with respect to file handling.

You might investigate the csv module that Python offers [1], and use
it to write CSV. Excel can import that very easily. Hell, simply
writing a list of filenames delimited by \n might be importable into
Excel.

[1]: http://docs.python.org/library/csv.html

--
Jed Smith
jed at jedsmith.org


More information about the Tutor mailing list