Splitting lines from a database query
Peter Machell
peter at machell.net
Tue Dec 26 16:57:12 EST 2006
Scott David Daniels wrote:
> Peter Machell wrote:
>> ZeD wrote: <An excellent response providing code>
>>
>> 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 newsgroup to
> write your code for you. Come back with your efforts and any problems
> you have with them.
As we say in Australia, fair enough.
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>"+fname+"</FNAME>"+"<SNAME>"+sname+"</SNAME>"
Except that I should be using a list and loop to do the null checking,
and it still stops when (I think) it hits a blank value:
TypeError: cannot concatenate 'str' and 'NoneType' objects
thanks,
Peter.
More information about the Python-list
mailing list