MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Lists and Loops

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113003] Lists and Loops
  • From: Michaell Taylor <Michaell.Taylor at boxwoodmeans.com>
  • Date: Sun, 10 Oct 2010 06:43:12 -0400 (EDT)
  • Reply-to: Michaell.Taylor at boxwoodmeans.com

I am new to Mathematica and am probably too stuck in other languages, but
but having a hard time with a simple listing building looping structure.
 The code below is supposed to cycle through a list of stock tickers.  For
each ticker it builds a list of certain financial data elements and adds
each element to a list.  When the list is complete (all financial elements
obtained), the list is written to a Mysql database.  The internal looping
structure seems to work fine.  That is, if I execute the internal loop for a
single ticker, the results are added to the database as planned.

However, the outer structure causes a problem in that the list continues to
grow with each ticker.  The "mydata={}" line was meant to "reset" the list,
but doesn't seem to be performing as expected.

 tickers = {"VNO", "AMB"}

fprop = {"Average50Day", "Average200Day"}

Do[
 mydata = {t}
   Do[
    mydata = Append[mydata, FinancialData[t, i]],
    {i, fprop}]
   Print[mydata]
   SQLInsert[connt, "reit" , {"ticker", "first", "second"}, mydata]
   {t, tickers}]


My error, no doubt is obvious to some. Any guidance would be greatly
appreciated.


=========================

Michaell Taylor, PhD

Principal
Boxwood Means, Inc.
Two Stamford Landing, Suite 100
68 Southfield Ave.
Stamford, CT 06902
http://www.boxwoodmeans.com
T: 203-653-4100
F: 203-653-5090



  • Prev by Date: double loop
  • Next by Date: Re: Generation of polynomials
  • Previous by thread: Re: double loop
  • Next by thread: Re: Lists and Loops