Created
July 30, 2013 16:06
-
-
Save rch850/6114330 to your computer and use it in GitHub Desktop.
鯖江市の地区別人口・世帯数の xls ファイルから合計だけ取ってくる。
xlrd の使い方は http://www.simplistix.co.uk/presentations/python-excel.pdf あたり参照。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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