On 12/11/2012 00:05, ejsa...@alaska.edu wrote:
with open("/home/eyalak/Documents/weather/weather.csv", "wb") as f: writer = csv.writer(f) table = soup.findAll("table")[3] #print table for tr in table.findAll("tr", valign="top"): a={x.string for x in tr.findAll('td')} print str(a) writer.writerows([a]) It did not work unless I changed the line a={x.string for x in tr.findAll('td')} to a=list({x.string for x in tr.findAll('td')}) But that disorganizes the data. How can I write the data to a csv file without altering the order prior to the list function. Thanks E
Change the line print str(a) to print type(a), a You'll see what the problem is and be able to fix it. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list