Q&A
pythonを使ってexcelデータを読み込み、そのデータをmysqlに入れたいのですが、最初の段階のデータの読み込みがうまくいきません。
import glob
import xlrd
files = glob.glob('/Users/xxx/xxxx/xxxxx/xxxxxx/*.xlsx')
book = xlrd.open_workbook(files[0])
sheet_1 = book.sheet_by_index(0)
for col in range(sheet_1.ncols):
for row in range(sheet_1.nrows):
items = sheet_1.cell(row,col).value
print items[1]
としても
IndexError: string index out of range
となってしまいます。
また
book = xlrd.open_workbook(files[0])
sheet_1 = book.sheet_by_index(0)
for col in range(sheet_1.ncols):
for row in range(sheet_1.nrows):
print sheet_1.cell(row,col).value
とすると値は返ってきます。
ただ、のちにmysqlにデータを入れたいのでitemsに値が入ってくれないと困ります><
どなたか解決策をご存知の方がいらっしゃいましたら、宜しくお願いしますm(__)m
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2015/07/29 04:21
2015/07/29 07:43
2015/07/31 05:27
2015/08/03 03:27
2015/08/04 13:34
2015/08/06 06:56