This one has been bugging me for the last few hours. I'm trying to execute a python cgi script that reads from a csv file and depending on the outcome would print a pass or fail. When running the script independently I would get a result looking like
- Pass
- Fail
- Pass
etc.
When running the script not in a cgi script, the process goes through the entire csv before finishing.
With cgi I get
- Pass
And then the script stops. I've tried incrementing both the outer and inner loop and I can't get it to work. Help would be greatly appreciated.Here is the sample code
def adst():
MyValues = []
values = csv.reader(open('sample.csv', 'U'), delimiter=',')
for row in values:
tcId = row[0]
colvalue = row[6]
listofvalues = []
listofvalues.append(colvalue)
response = urllib2.urlopen(row[7])
urls = response.read()
response.close()
dom = parseString(urls)
adimpression = urls.count('word')
pdis = urls.count('lines')
if word == 1:
print "Success!"
print tcId
if lines == 5:
print "Success"
else:
if word <= 0:
print "Fail"
form = cgi.FieldStorage()
tag1 = "at"
header("Connected ...")
index = 0
if form.has_key("tag") and form["tag"].value == tag1:
adst()
index +=1
else:
header("No success!")
print "<H3>Fail!</H3>"
footer()
Thanks
Jason