Giter Site home page Giter Site logo

rfokou / python-docx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikemaccana/python-docx

0.0 2.0 0.0 861 KB

Reads, queries and modifies Microsoft Word 2007/2008 docx files.

Home Page: mailto:[email protected]

License: MIT License

Makefile 1.58% Python 98.42%

python-docx's Introduction

########### This Project Has Moved! ###########

Python DocX is now part of Python OpenXML. There's all kinds of new stuff, including Python 3 support, sister libraries for doing Excel files, and more. Check out the current Python DocX GitHub and the current Python DocX docs.

Info below is kept for archival purposes. Go use the new stuff!

Introduction

The docx module creates, reads and writes Microsoft Office Word 2007 docx files.

These are referred to as 'WordML', 'Office Open XML' and 'Open XML' by Microsoft.

These documents can be opened in Microsoft Office 2007 / 2010, Microsoft Mac Office 2008, Google Docs, OpenOffice.org 3, and Apple iWork 08.

They also validate as well formed XML.

The module was created when I was looking for a Python support for MS Word .docx files, but could only find various hacks involving COM automation, calling .Net or Java, or automating OpenOffice or MS Office.

The docx module has the following features:

Making documents

Features for making documents include:

  • Paragraphs
  • Bullets
  • Numbered lists
  • Document properties (author, company, etc)
  • Multiple levels of headings
  • Tables
  • Section and page breaks
  • Images

image

Editing documents

Thanks to the awesomeness of the lxml module, we can:

  • Search and replace
  • Extract plain text of document
  • Add and delete items anywhere within the document
  • Change document properties
  • Run xpath queries against particular locations in the document - useful for retrieving data from user-completed templates.

Getting started

Making and Modifying Documents

  • Just download python docx.
  • Use pip or easy_install to fetch the lxml and PIL modules.
  • Then run:

    example-makedocument.py

Congratulations, you just made and then modified a Word document!

Extracting Text from a Document

If you just want to extract the text from a Word file, run:

example-extracttext.py 'Some word file.docx' 'new file.txt'

Ideas & To Do List

  • Further improvements to image handling
  • Document health checks
  • Egg
  • Markdown conversion support

We love forks, changes and pull requests!

  • Check out the [HACKING](HACKING.markdown) to add your own changes!
  • For this project on github
  • Send a pull request via github and we'll add your changes!

Want to talk? Need help?

Email [email protected]

License

Licensed under the MIT license

Short version: this code is copyrighted to me (Mike MacCana), I give you permission to do what you want with it except remove my name from the credits. See the LICENSE file for specific terms.

python-docx's People

Contributors

bjlange avatar djinn avatar femesq avatar gtozzi avatar lannybroo avatar laurentb avatar mikemaccana avatar punchagan avatar ranosch avatar reinspijkerman avatar toofishes avatar whatisdot avatar wichert avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.