Newbie needs help with regex strings

Catalina Scott A Contr AFCA/EVEO scott.catalina.ctr at scott.af.mil
Wed Dec 14 10:23:01 EST 2005


I have a file with lines in the following format.

pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon'
Pie=peach,quantity=2,ingredients='peaches,powdered sugar'
Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and sugar'

I would like to pull out some of the values and write them to a csv
file.

For line in filea
	pie = regex
	quantity = regex
	cooked = regex
	ingredients = regex
	fileb.write (quantity,pie,cooked,ingredients)

How can I retreive the values and assign them to a name?

Thank you
Scott



More information about the Python-list mailing list