Re: Splitting lines from a database query

2006-12-26 Thread John Machin
Peter Machell wrote: > Scott David Daniels wrote: > > Peter Machell wrote: > >> ZeD wrote: > >> > >> Thanks very much ZeD. This will do what I need to. > >> The next step is to do some regex on the phone number to ensure it's > >> local and correct. How can I split these up so each value has a key

Re: Splitting lines from a database query

2006-12-26 Thread Gabriel Genellina
At Tuesday 26/12/2006 18:57, Peter Machell wrote: for x in bar: fname = x[0] if fname == "": fname == "None" sname = x[1] if sname == "": sname == "None" print ""+fname+""+""+sname+"" Except that

Re: Splitting lines from a database query

2006-12-26 Thread Scott David Daniels
Peter Machell wrote: > I can almost do it this way: > > for x in bar: > fname = x[0] > if fname == "": > fname == "None" > sname = x[1] > if sname == "": > sname == "None" > > print ""+fname+""+""+sname+""

Re: Splitting lines from a database query

2006-12-26 Thread Peter Machell
Scott David Daniels wrote: > Peter Machell wrote: >> ZeD wrote: >> >> Thanks very much ZeD. This will do what I need to. >> The next step is to do some regex on the phone number to ensure it's >> local and correct. How can I split these up so each value has a key? > > Well, you should try that,

Re: Splitting lines from a database query

2006-12-26 Thread Scott David Daniels
Peter Machell wrote: > ZeD wrote: > > Thanks very much ZeD. This will do what I need to. > The next step is to do some regex on the phone number to ensure it's > local and correct. How can I split these up so each value has a key? Well, you should try that, unless you intend to get the newsgrou

Re: Splitting lines from a database query

2006-12-26 Thread Peter Machell
ZeD wrote: > Peter Machell wrote: > >> I have an application where I need to take a query from an existing >> database and send it to a web api. > > [...] > >> There are always 5 values, but some are blank and some are 'None'. >> I'd like to split the lines so I get something resembling XML, lik

Re: Splitting lines from a database query

2006-12-26 Thread ZeD
Peter Machell wrote: > I have an application where I need to take a query from an existing > database and send it to a web api. [...] > There are always 5 values, but some are blank and some are 'None'. > I'd like to split the lines so I get something resembling XML, like this: > Frank > Spencer

Splitting lines from a database query

2006-12-26 Thread Peter Machell
I have an application where I need to take a query from an existing database and send it to a web api. Here's a cut down version of my existing code: for foo in mssql.fetch_array(); bar = foo[2] #trims the first result which we don't use for x in bar: for y in x