Monday, February 20, 2006

nevow ,the templating engine from twisted needs Zope.

I installed nevow, the templating engine from twisted to create web pages on windows. The problem was that I had to install zope for windows as well. I don't now why.
I plan to use this templating engine because my web page generating scripts are very ugly, with plenty of if, elif, elif and one cannot find the structure of a web page in there.

Monday, February 06, 2006

xls2csv, using python win32com and excel

This python script change a bunch of excel files in cvs files, needs Excel installed on the computer.

#
# Save all Excel files in the current dir as csv files
# (CSV = comma separeted values)

from win32com.client import Dispatch
import os,time

xlCSV = 6 #a vba constant for this fileformat
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1

def saveAsCSV(filename):
xlApp.Workbooks.Open(filename)
xlApp.ActiveWorkbook.SaveAs(filename[:-3]+"csv",xlCSV)
xlApp.ActiveWorkbook.Close(SaveChanges=0)

for root, dirs, files in os.walk(''):
for file in files:
if ".xls" in file:
print file
saveAsCSV(os.path.abspath(file))
xlApp.Quit()
del xlApp

If you need to do this on linux, you can try that program: xls2csv.