Re: help with lists and writing to file in correct order

2005-12-30 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hey mike-the sample code was very useful. have 2 questions > > when i use what you wrote which is listed below i get told > unboundlocalerror: local variable 'product' referenced before > assignment. You would get this error if you have a that doesn't have an . Do y

Re: help with lists and writing to file in correct order

2005-12-29 Thread homepricemaps
hey mike-the sample code was very useful. have 2 questions when i use what you wrote which is listed below i get told unboundlocalerror: local variable 'product' referenced before assignment. if i however chnage row to incident in "for incident in bs('tr'):" i then get mytuples printed out nicel

Re: help with lists and writing to file in correct order

2005-12-29 Thread Mike Meyer
[EMAIL PROTECTED] writes: > hey kent thanks for your help. > > so i ended up using a loop but find that i end up getting the same set > of results every time. the code is here: > > for incident in bs('tr'): > data2 = [] > for incident in bs('h2', {'id' : 'dealName'}): >

Re: help with lists and writing to file in correct order

2005-12-29 Thread homepricemaps
hey kent thanks for your help. so i ended up using a loop but find that i end up getting the same set of results every time. the code is here: for incident in bs('tr'): data2 = [] for incident in bs('h2', {'id' : 'dealName'}): product2 = "" fo

Re: help with lists and writing to file in correct order

2005-12-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > sorry guys, here is the code > > for incident in bs('a', {'class' : 'price'}): > price = "" > for oText in incident.fetchText( oRE): > price += oText.strip() + "','" > > for incident in bs('div', {'class' : 'store'}): > st

Re: help with lists and writing to file in correct order

2005-12-28 Thread Steven D'Aprano
On Tue, 27 Dec 2005 20:11:59 -0800, homepricemaps wrote: > hey steven-your examlpe was very helpful. is there a paragraph symbolg > missing in > > fp.write("Food = %s, store = %s, price = %s\n" % triplet No, but there is a closing bracket missing: fp.write("Food = %s, store = %s, price = %s\n"

Re: help with lists and writing to file in correct order

2005-12-27 Thread homepricemaps
hey steven-your examlpe was very helpful. is there a paragraph symbolg missing in fp.write("Food = %s, store = %s, price = %s\n" % triplet Steven D'Aprano wrote: > On Mon, 26 Dec 2005 20:56:17 -0800, homepricemaps wrote: > > > sorry for asking such beginner questions but i tried this and nothing

Re: help with lists and writing to file in correct order

2005-12-27 Thread Siraj Kutlusan
Why don't you use pickle instead of directly writing to the file yourself? -- http://mail.python.org/mailman/listinfo/python-list

Re: help with lists and writing to file in correct order

2005-12-27 Thread Steven D'Aprano
On Mon, 26 Dec 2005 20:56:17 -0800, homepricemaps wrote: > sorry for asking such beginner questions but i tried this and nothing > wrote to my text file > > for food, price, store in bs(food, price, store): > out = open("test.txt", 'a') > out.write (food + price + stor

Re: help with lists and writing to file in correct order

2005-12-26 Thread bonono
[EMAIL PROTECTED] wrote: > sorry for asking such beginner questions but i tried this and nothing > wrote to my text file > > for food, price, store in bs(food, price, store): > out = open("test.txt", 'a') > out.write (food + price + store) >

Re: help with lists and writing to file in correct order

2005-12-26 Thread homepricemaps
sorry for asking such beginner questions but i tried this and nothing wrote to my text file for food, price, store in bs(food, price, store): out = open("test.txt", 'a') out.write (food + price + store) out.close() while if i write

Re: help with lists and writing to file in correct order

2005-12-26 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > the problem with writing to teh file immidiately is that it ends up > writing all food items together, and then all store items and then all > prices > > i want > > food, store, price > food, store, price > Well, if it all fits in memory, append each to its own list, a

Re: help with lists and writing to file in correct order

2005-12-26 Thread homepricemaps
the problem with writing to teh file immidiately is that it ends up writing all food items together, and then all store items and then all prices i want food, store, price food, store, price -- http://mail.python.org/mailman/listinfo/python-list

Re: help with lists and writing to file in correct order

2005-12-26 Thread homepricemaps
here is the write part: out = open("test.txt", 'a') out.write (store+ food+ price + "\n") out.close() Steven D'Aprano wrote: > On Mon, 26 Dec 2005 17:44:43 -0800, homepricemaps wrote: > > > sorry guys, here is the code > > > > for incident in bs('a', {'class' : 'price'}): >

Re: help with lists and writing to file in correct order

2005-12-26 Thread Steven D'Aprano
On Mon, 26 Dec 2005 17:44:43 -0800, homepricemaps wrote: > sorry guys, here is the code > > for incident in bs('a', {'class' : 'price'}): > price = "" > for oText in incident.fetchText( oRE): > price += oText.strip() + "','" > > for incident in bs('div', {

Re: help with lists and writing to file in correct order

2005-12-26 Thread homepricemaps
sorry guys, here is the code for incident in bs('a', {'class' : 'price'}): price = "" for oText in incident.fetchText( oRE): price += oText.strip() + "','" for incident in bs('div', {'class' : 'store'}): store = "" for oText in incident.fetc

Re: help with lists and writing to file in correct order

2005-12-26 Thread Steven D'Aprano
On Mon, 26 Dec 2005 13:54:37 -0800, homepricemaps wrote: > hey folks, > > have a logic question for you. appreciate the help in advance. > > i am scraping 3 pieces of information from the html namely the food > name , store name and price. and i am doing this for many different > food items fo