The following code does not output any data except: col1 [none]
in my .csv file. There are no errors though.
I am hoping to get one column with about 50 rows of text rows. Thanks for any help in advance. If it is possible to put the name, workab and abstract in separate columns that would also be of great help.
def output():
headernum = 0
i = 0
x = soup.find_all("h1")
for i in range(len(x)):
header = soup.find_all('h1')[headernum]
name = header.find_all_next('p')[1]
nameab = name.text
#print(nameab.replace("\n",""))
workplace = name.find_all_next('i')[0]
workplace2 = name.find_all_next('i')[1]
workab = workplace.text + workplace2.text
#print(workab.replace("\n",""))
abstract = []
for elem in name.next_siblings:
if elem.name == 'h1':
break
if elem.name != 'p':
continue
abstract.append(elem.get_text())
a = "**".join(abstract).replace("\n", " ").encode('utf-8')
i += 1
headernum += 1
def output2():
x = soup.find_all("h1")
l = []
for i in range(1):
l.append(output())
def fileOut():
myData = ['Col1',[output2()]]
myFile = open('test.csv', 'w')
with myFile:
writer = csv.writer(myFile)
writer.writerows([myData])
myFile.close()
fileOut()