Dumping data from Excel files

posted on 08:49 AM on Tuesday 21 July 2015

In my area of work, Excel files are the predominant form of data storage which is quite sad. And the amount of data kept in these files can be rather large. So I wrote a small python script to dump out the data in tab delimited form to STDOUT using openpyxl.

#!/usr/bin/env python

from openpyxl import load_workbook
import sys
import string

wb = load_workbook(sys.argv[1], read_only=True)
for ws in wb:
        for row in ws.rows:
                print string.join([ws.title] + map(lambda x: str(x.value), row), "\t")

Not bad for 4 lines of actual codes.

bernett.net