Broken examples
Tim Roberts
timr at probo.com
Fri Jul 25 01:33:59 EDT 2008
norseman <norseman at hughes.net> 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.
>
>Outline:
> cd somedir
> ls -1 *.xls >thislist #ls hyphen one
> python process.py
> (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
model.
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 )
wb.Close()
If you want to watch the progress, add "excel.Visible=1" after the
dispatch.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list