Created
April 22, 2021 09:45
-
-
Save mmdbalkhi/52093f55788fc184ee23ee4c5e9b05e4 to your computer and use it in GitHub Desktop.
read docx file with python in command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
from docx import Document | |
@click.command() | |
@click.argument('path', type=click.Path(exists=True, readable=True, | |
resolve_path=True, dir_okay=True)) | |
def read(path): | |
document = Document(path) | |
for para in document.paragraphs: | |
click.echo(para.text) | |
if __name__ == '__main__': | |
read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read docx file with python in command line
prerequisites:
pip3 install click
pip3 install python-docx
Usage:
python docx_read.py path/to/file