Alteryx Designer

Find answers, ask questions, and share expertise about Alteryx Designer.
Register for the upcoming Live Community Q&A Session - and don't forget to submit your questions for @DeanS regarding the future role of analytics here.
SOLVED

How to use R and Python to Parse Word Documents

Highlighted
Alteryx
Alteryx

@mceleavey unfortunately that example probably won't lend itself well for that scenario.

 

Python or other R packages may get you closer  - 

 

might be worth starting a new thread and seeing if anyone has anything that could solve it.

Highlighted
Alteryx Certified Partner

Cheers, Shaan. Thanks for all your help.

 

M.

Highlighted
Alteryx
Alteryx

Hi everybody!

 

Looks like https://python-docx.readthedocs.io/en/latest/ (Python-DocX) might be what you need Chris, if you're going down the Python route? 

 

Cheers,

Nick

Nick Jewell | Alteryx Product Strategy
Highlighted
Alteryx Certified Partner

mceleavey_0-1579612266705.png

 

Dr. Nick, you magnificent human being!

I will give that a try now.

Highlighted
Alteryx Certified Partner

Unfortunately, that doesn't appear to do what I need. I need to read in .doc files including the values selected in a drop-down. I've found a python package called Textract which claims to do this, but I can't get it working. I'm not at all competent with Python, so it's definitely user error. I've installed the package, and defined the filepaths so I can use it, but it returns a File Not Found error.

 

I'll keep plugging away...

Highlighted
8 - Asteroid

Hi ShaanM,

 

OK thank you. I have sent Support an e-mail. I will respond to this thread if a solution is found.

Highlighted
8 - Asteroid

Hi Everyone,

 

I spoke with Support and I do have a solution that has worked for me for reading Word docs in the Python tool.

 

1) to install external packages you have to do it in the Admin version of Alteryx. Right click on the Alteryx icon and select 'Run as administrator'

G1_0-1579824908229.png

 

2) drag the python tool onto the canvas and click on it. Type the following into a cell: 

 

from ayx import Alteryx
Alteryx.installPackages("docx2txt")

 

Keep the cell selected and hit the 'Run' button within the Python tool itself (not the Alteryx Run Workflow button)

G1_1-1579823034934.png

 

This should install the package onto your computer. You should now be able to use it in the non-admin version of Alteryx. You should not have to do this admin step again for this package (but you will if you want to install others)

 

3) Open up the non-admin version of Alteryx and drag a Python tool onto the workflow

 

4) Now the package is installed you need to import its features into your Python kernel. Type the following into a cell:

 

from ayx import Alteryx
import pandas
import docx2txt

 

You need to import pandas too since the Word document conversion is to a pandas df.

 

5) Make sure that the Python tool is sourcing from the correct file directory where your Word document is saved; use the 'cd' (change directory) command to do this:

 

cd C:\Your\File\Path\Here\

 

6) Use the following statement to read in your Word Document:

 

docx2txt.process("File_Name.docx")

 

G1_2-1579824156863.png

 

Hope this works for everyone! I've attached my test Word docx file if anyone wants to use it.

 

I have not got the PDF read-in to work yet but I will update if I do.

Labels