Rameshwari wrote: > > Hi, > > I would like to read a ms-word document using python. > > Basically the word document contains number of tables and the rows > in each table do not have same number of columns. > > Does anyone have a sample code to read a table? > > Thank you > Best Regards, > Rameshwari
The following code should return a list of list of lists (tables->table->rows->cells) for the active document in Microsoft Word. Warning! Untested code ######################## import win32com.client def GetTables(): app = win32com.client.Dispatch('Word.Application') doc = app.Documents[0] tables = [] for word_table in doc.Tables: table = [] for word_row in word_table.Rows: row = [cell.Range.Text for cell in word_row.Cells] table.append(row) tables.append(table) return tables -- Andrew Henshaw Georgia Tech Research Institute -- http://mail.python.org/mailman/listinfo/python-list