473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Read word tables


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


Jul 18 '05 #1
2 9273
Am Tue, 21 Dec 2004 11:24:35 +0000 schrieb Rameshwari:

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?


Hi,

There is a small script[1] which parses the XML produced
by Excel. Something like this should be possible for msword, too.

Other way: You can export to the openoffice format and unzip it.
The read these xml files.

HTH,
Thomas

[1]:http://aspn.activestate.com/ASPN/Coo.../Recipe/192914

--
Thomas Güttler, http://www.thomas-guettler.de/
Jul 18 '05 #2
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

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marco | last post by:
I need to know if is possible to read oracle tables from PostgresSQL (and vice versa). Can someone give me some help? Thanks a lot
3
by: Phil Rutter | last post by:
Hello All, I have about 700 word documents that have 2 tables one is static 4 colums x 5 rows the other is 5 colums x rows ranging from 2 to 100 what i wolud like to do is open the word doc....
0
by: Josema | last post by:
Hi to all, Im trying to identify separately the tables and the paragraphs of a word document.. When i use the Word.Paragraphs interface to get all the paragraphs of a document i see that...
8
by: Tim Murphy | last post by:
How do you read/write a Word document embedded in an OLE Object field in an Access table with VB.NET? I have an Access application where users are creating and editing Word documents that are...
2
by: sebastien1101 | last post by:
i need to make a Table in RTF in my richTextBox... I can't find any sample to help me to begin this works... If someone have a little sample... thx
3
by: Jay | last post by:
Hi, I need to read word document file in ASP.net and place it in a text box . How to do it ? i tried : Word.Application app = new Word.ApplicationClass(); object nullobj =...
1
by: kumarm | last post by:
Hi I need some help reagrding how to read word document line by line using vb.net program?. I have a word object created by using vb.net program which opens a word document.Using this object my...
4
by: Alexander Vasilevsky | last post by:
Need to read Word file without Office installation. It's possible? http://www.alvas.net - Audio tools for C# and VB.Net developers
1
by: Mohd Nazim Quadri | last post by:
can i read word document file by php?if, yes then tell me how?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.