[Tutor] Need all values from while loop - only receiving one

Daryl Heppner darylheppner at gmail.com
Wed Jul 4 07:08:17 EDT 2018

Hi Alan,

Extremely valuable guidance - thank you!  I will be adapting my script
once I get to the office but at a first glance, this appears to be
exactly what we need!  I'll confirm once I've had a chance to
implement this.

If you have any suggestions for continued self-learning (books,
courses, etc.) I'd appreciate any tips.

A bit of context, in case you're curious - we're parsing the XML for
load into a T SQL database for reporting purposes which is why I've
parsed each value to a unique "cell".  The print statement is merely a
QA step before ultimately making use of the pyodbc method.

For our Base Rent table, the final Python statement reads as:

x.execute("Insert into dealbaserents (dealid, dtermid, brentid, \
brbegin, brentamt, brentperiod, brentdur) values \
(?, ?, ?, ?, ?, ?, ?)", \
(dealid, dtid, brid, begmo, brentamt, brper, duration))

The need to extrapolate the full rent schedule is to address a few
reporting needs.  Free Rent, where applicable, is not expressed as a
dollar value with a specific date.  Rather, it is described as a
percentage of Base Rent with a reference to the month in which it
applies.  A lease can have multiple Free Rent periods which may or may
not be consecutive and there are several examples where a Free Rent is
applied in the 2nd month and again in the 14th month which means that
the dollar value of the Free Rent could be different if a rent step
occurs at the end of the first year.

We will also be calculating Net Present Value which will be much
easier to deal with using normalized data.  There are four scenarios
for calculating base rent - per square foot per month, per square foot
per year, monthly amount and annual amount.



On Tue, Jul 3, 2018 at 8:16 PM Alan Gauld via Tutor <tutor at python.org> wrote:
> On 04/07/18 01:08, Alan Gauld via Tutor wrote:
> > # Now the main code just needs the outer loops:
> > tree = ET.parse(r'\\DealData.xml')
> > root = tree.getroot()
> > deals = []
> > for deal in root.findall("Deals"):
> >     for dl in deal.findall("Deal"):
> >         deals.append( Deal(dl) )
> >
> >         if dl.id == "706880":
> >            print(dl)  #uses __str__() to create string
> Sorry, that last loop should be like this:
>      for xml_dl in deal.findall("Deal"):
>          theDeal = Deal(xml_dl)
>          deals.append( theDeal )
>          if theDeal.id == "706880":
>             print(theDeal)  #uses __str__() to create string
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list