Broken examples

Tim Roberts timr at
Fri Jul 25 07:33:59 CEST 2008

norseman <norseman at> wrote:
>I'm only talking about IPC related.
>I have googled, yahooed, and so forth for several months now. ALL 
>examples I've come across have failed including those pertinent in the 
>Python doc area.
>	cd somedir
>	ls -1 *.xls >thislist      #ls hyphen one
>	python
>                 (yes - ls can go here if wanted. easier to edit outside)
>		open thislist
>		loop until done
>			start excel (or scalc)
>			have it open file
>			have it save file as a .csv (or .dbf)
>			close excell (or scalc)
>Would seem to be a trivial exercise.

Excel is a COM-driven application.  You have to drive it through the object

  import win32com.client
  excel = win32com.client.Dispatch( 'Excel.Application' )
  xlCSV = 6
  for nm in list_of_file_names:
    csv = os.path.splitext( nm )[0] + '.csv'
    wb = excel.Workbooks.Open( nm )
    wb.SaveAs( csv, xlCSV )

If you want to watch the progress, add "excel.Visible=1" after the
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list