Reading boldface text from .doc or .docx files to lists

This is the place for queries that don't fit in any of the other categories.

Reading boldface text from .doc or .docx files to lists

Postby bertenjourney » Wed Sep 11, 2013 2:07 am

Hi.
I am fairly new to Python. I have a job where I have to open .doc or .docx documents and insert their content into Python lists. I can currently do this word-for-word and line-for-line fairly easily, but I need to find a way to read only boldface words into the list. Is this possible? Any help would be much appreciated.

code sample:
Code: Select all
#put lines of file into array called fileLines
f = open(self.fileName, "r")            #open specified for reading
array = []                              #create 1-dimensional array to store individual lines
wordArray = []                          #create 1-dimensional array to store individual words
for i in f:                             #for each line in file
    array.append( i )                   #put line in array
for lines in array:                     #for each element of array
    wordArray.append(lines.split())     #create array with just words
Last edited by Mekire on Wed Sep 11, 2013 6:43 am, edited 1 time in total.
Reason: Please use code tags. First post lock.
bertenjourney
 
Posts: 1
Joined: Wed Sep 11, 2013 1:56 am

Re: Reading boldface text from .doc or .docx files to lists

Postby vijaykumbhani » Fri Sep 13, 2013 5:17 am

you use below link
i think your answer in link

https://github.com/mikemaccana/python-docx
[b][i]With Regards,
Vijay Kumbhani[/i][/b]
vijaykumbhani
 
Posts: 33
Joined: Wed Aug 14, 2013 4:26 am
Location: Surat, Gujarat, India


Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 5 guests