Skip to content

Instantly share code, notes, and snippets.

@mmdbalkhi
Created April 22, 2021 09:45
Show Gist options
  • Save mmdbalkhi/52093f55788fc184ee23ee4c5e9b05e4 to your computer and use it in GitHub Desktop.
Save mmdbalkhi/52093f55788fc184ee23ee4c5e9b05e4 to your computer and use it in GitHub Desktop.
read docx file with python in command line
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()
@mmdbalkhi
Copy link
Author

Read docx file with python in command line

prerequisites:

Usage:

  • python docx_read.py path/to/file

test.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment