import glob
from bs4 import BeautifulSoup
f = open('csvfile.csv','w')
for file in glob.glob('*.htm'):
print 'Processing', file
for y in range(0,3):
for x in range(0, 6):
soup = BeautifulSoup(open(file).read())
all_string=soup.find_all("h2")[x].get_text()
#stack=[]
#acct.write(", ".join(stack) + '\n')
f.write(all_string)
f.write('\n')
print(all_string)
x=0
f.close()
を解決し得ていない処理アルカリ制御C-H切断またはN2由来の鉄窒化物およびイミドによるN-C結合形成 - のジャーナル米国化学会(ACS出版)の.htm
抽象
サポート情報
周囲の反応条件の下でシリルアミンへの分子二窒素の バナジウム触媒還元
Traceback (most recent call last):
File "", line 1, in runfile('/Users/ROXX/Desktop/project/csv1.py', wdir='/Users/ROXX/Desktop/project')
File "/Users/ROXX/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 880, in runfile execfile(filename, namespace)
File "/Users/ROXX/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile builtins.execfile(filename, *where)
File "/Users/ROXX/Desktop/project/csv1.py", line 17, in all_string=soup.find_all("h2")[x].get_text()
IndexError: list index out of range
ありがとうございます。データを収集し、.csvファイルの列で破損していることを探してください。そのためのコマンドや方法を知りたい。 –
ここをクリックhttp://www.pythonforbeginners.com/systems-programming/using-the-csv-module-in-python/ –