Skip to content

Instantly share code, notes, and snippets.

@rch850
Created July 30, 2013 16:06
Show Gist options
  • Save rch850/6114330 to your computer and use it in GitHub Desktop.
Save rch850/6114330 to your computer and use it in GitHub Desktop.
鯖江市の地区別人口・世帯数の xls ファイルから合計だけ取ってくる。 xlrd の使い方は http://www.simplistix.co.uk/presentations/python-excel.pdf あたり参照。
import xlrd
import sys
if len(sys.argv) < 2:
print "python %s xxx.xls" % sys.argv[0]
sys.exit(1)
filename = sys.argv[1]
if filename.startswith("http"):
from urllib import urlopen
book = xlrd.open_workbook(file_contents=urlopen(filename).read())
else:
book = xlrd.open_workbook(sys.argv[1])
for sheet in book.sheets():
print sheet.name, sheet.cell(sheet.nrows - 1, sheet.ncols - 1).value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment