Skip to content

Instantly share code, notes, and snippets.

View amandagrams's full-sized avatar
👻

Amanda amandagrams

👻
View GitHub Profile
@amandagrams
amandagrams / docxtables.py
Created April 18, 2020 03:09 — forked from jnothman/docxtables.py
Load tables from Word docx to pandas dataframe
import zipfile
from lxml import etree
import pandas as pd
def read_docx(docx_file, **kwargs):
"""Read tables as DataFrames from a Word document
"""
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
with zipfile.ZipFile(docx_file).open('word/document.xml') as f:
root = etree.parse(f)