FRED2 Database


               Moody's Seasoned Aaa Corporate Bond Yield
Series ID:           AAA
Source:              Reprinted with permission from Moody's Investors Service. Copyright.
Release:             Not Applicable
Seasonal Adjustment: Not Applicable
Frequency:           Monthly
Units:               Percent
Area Chart
<script language="VB" runat="server">
  Dim HowTo As New Tornado.z
  Dim u As New Tornado.Util
  Dim GD As New Tornado.GetData
  Dim DataDir As String = "/tornado/db/fred2/txt/"
  Sub Page_Load(Src As Object, E As EventArgs)
    Dim sel, first As String
'...Read data only once
    If Not HowTo.ASPdbPostBack Then
'...Include all and Exclude alien files like ReadMe*.*
      Session("Names") = u.Get_Filenames(DataDir & "*.txt", DataDir & "readme*.*", 2, ",")
'... Set the init display page
      Dim Arr() As String = Split(Session("Names"), ",", 2)
      first = Arr(0)
    End If

    With HowTo
      .dbQP = "U=1|S=aspdb|th=title=FRED2 Database"
      .dbMode = "type=SBox|SboxLabel=Series:&nbsp;|SboxMacro=({{" & Session("Names") & "}})"
    End With
    sel = GD.Get_SelectBoxFormSelection()
    If sel = "" Then sel = first
    Plot_it(DataDir & sel & ".txt")
    Response.Write(Write_The_Rest(DataDir & sel & ".txt"))
  End Sub

  Private Sub Plot_it(ByVal aFile As String)
  Dim Master As String = u.ReadFile(aFile)
  Dim Title As String = u.FastSandwich(Master, "Title:", "eol")
  Dim XYData() As String = Split(Replace(u.FastSandwich(Master, "VALUE" & vbCrLf, "eof"), " ", ","), vbCrLf)
  Dim i As Integer, x, y, le, ri As String
  For i = 0 To UBound(XYData)
    u.Split2(XYData(i), le, ri, ",")
    x &= IIf(i > 0, ",", "") & le
    y &= IIf(i > 0, ",", "") & ri

  With HowTo
    .dbUnit = 2
    .dbChartParams = "titlestring=FRED2 Chart"
    .dbDateLineChart = " inputDateFormat=yyyy-MM-dd| Name0=Fred2| Date0=" & x & "| Value0=" & y
  End With
  End Sub

  Private Function Write_The_Rest(ByVal sel As String) As String
  Dim Master As String = u.ReadFile(sel)
  Dim TheRest As String = u.FastSandwich(Master, "Title:", "DATE", False, True)
  TheRest = Replace(TheRest, vbCrLf, "<br>")
  TheRest = Replace(TheRest, " ", "&nbsp;")
  Return ("<P><div align=middle><table><tr><td class=nr>" & TheRest & "</td></tr></table></div>")
  End Function


This is a real life application involving displaying data from a simple information source. This example represents a very common task of web enabling every day simple applications where the information is not designed for the web. The challenge is to web enable these applications without disturbing the information source or the tail should not wag the dog so to speak.

Mission - To develop an application to view the FRED II data series. Text data are displayed and the time series data are plotted as a time series chart. When new data is available, all need to be done is to download and unzip the data to the appropriate directory. No other maintenance is required.

  1. Checkout the datasource -> Federal Reserve Bank of St. Louis - Economic Data - FRED II
    Got to ->
  2. Select "Download All Data" and you be in the download screen. Download both the Text and XLS version.
  3. Unzip the two data sets to the following directories each with about 1,294 files -
  4.  Inspect the files from the data set and you'll notice that each file represents a data series of economic data (A sample of text data file). The Excel version has no data range defined and the position of the data and text is random. Hence we choose to use the text version as datasource instead of Excel version.
  5.  Application will first extract the data files and exclude the readme file in the directory; A Select DropDown Box will be built to allow selection of the series. Upon selection of the series, text data will be displayed and series data will be plotted.
  6.  Click the execute button at the end of the source code listing to see the 'Live Action' (Your browser must be Java Enabled). This application is done in about 55 lines of code. You can see how easy it is to web enable your desktop applications with this very powerful Tornado (ASPdb.Net) tool. Time spent on the source code is about 2 hours.