How can i read .docx file?
The easiest way is probably to use the Open XML SDK 2.0
Get Code Snippets for Visual Studio 2008 for some examples
And I would highly recommend downloading the Open XML SDK productivity tool which will help you understand how the Open XML files are structured, and can even help you generate source code to use with the SDK based on the structure of your documents. You can download the tool from the same page as the SDK. It's 100MB, but it's worth the download.
python: find numbers in docx file and replace
You can use the docx library to read the content of .docx files.
pip install python-docx
Adapting some code from here and combining with the code you posted I got:
import docx
def getText(filename):
doc = docx.Document(filename)
fullText = []
for para in doc.paragraphs:
fullText.append(para.text)
return '\n'.join(fullText)
text = getText('Doc1.docx')
a = [int(s) for s in text.split() if s.isdigit()]
which worked for me with a simple test file - although you may need to adjust some parts depending on how you want the search for numbers to work.
Related Topics
C#: How to Take a Screenshot of a Portion of Screen
Dictionary <String,String> Map to an Object Using Automapper
Can't See Localhost from Uwp App
How to Find the Parent Directory in C#
MVC 5 Dynamic Rows with Begincollectionitem
Passing Parameters to Xslt Stylesheet via .Net
Generic List of Generic Objects
Detect Change of Resolution C# Winforms
How to Ignore Get-Only Properties in JSON.Net Without Using JSONignore Attributes
Outofmemoryexception on Declaration of Large Array
Entity Framework Creates a Plural Table Name, But the View Expects a Singular Table Name
How to Translate a List<String> into a SQLparameter for a SQL in Statement