arch = "virtex5" command = "run" logfile = open('logfile','r') lines = logfile.readlines() logfile.close() expecting_attr = True expecting_desc = False expecting_opts = False buf = "" attr = "" descr = "" opts = () Description = {} Options = {} for line in lines: if expecting_attr: attr = line.split(":")[0].lstrip('-').rstrip(' ') descr = line.split(":")[1].lstrip(' ').rstrip('\r\n') Description[attr] = descr expecting_attr = False expecting_opts = True elif expecting_opts: Options[attr] = [option.lstrip('\t ').rstrip('\r\n ') for option in line.split('/')] expecting_attr = True expecting_opts = False import win32com.client Excel = win32com.client.Dispatch("Excel.Applcation") XST_Settings = Excel.Workbooks.Add() Row = 0 for attr in Options.iterkeys(): XST_Settings.Sheets(1).Cells(Row,1).Value = attr XST_Settings.Sheets(1).Cells(Row,2).Value = Description[attr] XST_Settings.Sheets(1).Cells(Row,3).Value = repr(Options[attr]) Row = Row + 1 XST_Settings.SaveAs('XST_%s_%s.xlsx'%(arch,command))