LoadBPVFromFile loads a two column comma delimited file where the first column is a date and the second column contains a numeric value.  Most often the user will created BPV Auto-Index enable Numeric Series. However, this function will support a BPV Auto-Index String Series.  

 

Think of the process this way:

1.All BPV series element values are initialized at the time of creation with the default value the user allows in the series creation.

2.The BPV will contain the values located in the second column for any test.currentDate locations that match a date record from the loaded file.

3.The series’ default value at a test.currentDate location will be found when a matching date wasn’t found in the loading file.

 

Syntax:

LoadBPVFromFile(fullPathFileString, numericSeriesBPVname)

 

Parameter:

Description:

fullPathFileString

The drive's letter and full path to the folder that contains the named file.

 

The file information needed to a load a file must be in the String that contain the fullPathFileString parameter text.  That parameter needs the text information to find and then load the two-column file.  In that string variable, the full-Path-name plus the File-name must match an actual directory's path location where the file name including its suffix is located (see the below example's "Setup the path for the file to Load into a BPV" section for how it might be obtained.)

numericSeriesBPVname

BPV Auto-Index enabled numeric series.

 

During the file loading process, all test.currentDate locations that match a loaded file record date will contain the loaded file's second column value at the test.currentDate date location that matched a record in the loaded file.  When the loaded file does not have a date record for a test.currentDate value, the initialize BPV Auto-Index enable Numeric Series  value won't be changed from its previous initialized value.

 

Example:

====================================================================
'  LoadBPVFromFile is an Import File Example available in the Blox MarketPlace

' https://tinyurl.com/y7slhqrl

'
'  In the example space below, a second BPV manually-indexed numeric series was created so the
'  value in the second column would have a series lookup location to display the holiday date name
'  that appears when the scripting display the second column value for the matching dates.

 
BLOCK: Load BPVFile into a Numeric Series
--------------------------------------------------------------------
Block Permanent Variables
--------------------------------------------------------------------
tBPV_SeriesName [ BPV Variable Series Name ]; Series String; 0.000000; Block
aHoliday [ Holiday as a YYYYMMDD Float ]; Series; 0.000000; Block
tPathName [ Any File Path Location String ]; String; ; Block
tFileName [ Any file name String ]; String; ; Block
tFullPathFileName [ BPV Load String Variable Name ]; String; ; Block
tHolidayNames [ Human readable name goes here... ]; Series String; 0.000000; Block
iFileFound [ True File Found ]; Integer; 0; Block
--------------------------------------------------------------------
Parameters
--------------------------------------------------------------------
VarToShowBlox [ Param to Displays System Blox ]; String; Block
--------------------------------------------------------------------
SCRIPT: Before Test
--------------------------------------------------------------------
'  ==============================================================
'  LoadBPVFromFile-Example
'  BEFORE TEST - START
'  ==============================================================
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Setup the path for the file to Load into a BPV
'  --------------------------------------------------------------
'  Assign a file path location (example uses
'  Example uses TB's default installation path.  
'  Example information file is placed in the default
'  path's data folder.
tPathName = fileManager.DefaultFolder + "Data\"
 
'  Give the file name the text name of the file.
tFileName = "US-Holiday-Series_20201225.csv"
 
'  Append the Path, the "\" and the Filename
'  to create a full File & Path name text value
tFullPathFileName = tPathName + tFileName
 
'  Validate File's Name and Location.
iFileFound = FileExists(tFullPathFileName)
'  --------------------------------------------------------------
'  Test the presence of the file.  If it is found, it will load
'  the file into the BPV variable 'holidays'
If iFileFound AND
  test.LoadBPVFromFile(tFullPathFileName, "aHoliday" ) THEN
ELSE
  '  When the conditional test fails, this
  '  error message will appear.
  MessageBox("Unable to Find or Load data!")
ENDIF '  test.LoadBPVFromFile...
 
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Holiday Name Lookup List
'  Holiday File Example uses the Holiday sequence number in the
'  the series name braces to select the holiday name to display
'  --------------------------------------------------------------
tHolidayNames[ 1] = "New Year Day"
tHolidayNames[ 2] = "Martin Luther King Jr. Day"
tHolidayNames[ 3] = "Presidents Day (Washingtons Birthday)"
tHolidayNames[ 4] = "Memorial Day"
tHolidayNames[ 5] = "Independence Day"
tHolidayNames[ 6] = "Labor Day"
tHolidayNames[ 7] = "Columbus Day"
tHolidayNames[ 8] = "Veterans Day"
tHolidayNames[ 9] = "Thanksgiving Day"
tHolidayNames[10] = "Christmas Day"
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  ==============================================================
'  BEFORE TEST - END
'  LoadBPVFromFile-Example
'  ==============================================================
--------------------------------------------------------------------
SCRIPT: Before Trading Day
--------------------------------------------------------------------
  '  ==============================================================
  '  LoadBPVFromFile-Example
  '  BEFORE TRADING DAY - START
  '  ==============================================================
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  Check Current Test Date to the Loaded Holiday dates.
  '  When a matching Holiday date is found, the name of
  '  the US Holiday will appear
  '  --------------------------------------------------------------
  '  Each new date it will show a holiday record
  '  That aligns with a holiday date
  If aHoliday != 0 THEN
    PRINT test.currentDate, _
          " is Holiday#: ", _
          AsInteger(aHoliday), _
          tHolidayNames[aHoliday]
  ENDIF
  '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  '  ==============================================================
  '  BEFORE TRADING DAY - END
  '  LoadBPVFromFile-Example
  '  ==============================================================

Returns:

Example above returns the annual sequence count of each of the ten US-Federal Holidays show next:

...[SNIP]

20141111  is Holiday#:  8 Veterans Day

20141127  is Holiday#:  9 Thanksgiving Day

20141225  is Holiday#:  10 Christmas Day

20150101  is Holiday#:  1 New Year Day

20150119  is Holiday#:  2 Martin Luther King Jr. Day

20150216  is Holiday#:  3 Presidents Day (Washingtons Birthday)

20150525  is Holiday#:  4 Memorial Day

20150703  is Holiday#:  5 Independence Day

20150907  is Holiday#:  6 Labor Day

20151012  is Holiday#:  7 Columbus Day

20151111  is Holiday#:  8 Veterans Day

20151126  is Holiday#:  9 Thanksgiving Day

20151225  is Holiday#:  10 Christmas Day

20160101  is Holiday#:  1 New Year Day

20160118  is Holiday#:  2 Martin Luther King Jr. Day

20160215  is Holiday#:  3 Presidents Day (Washingtons Birthday)

20160530  is Holiday#:  4 Memorial Day

20160704  is Holiday#:  5 Independence Day

20160905  is Holiday#:  6 Labor Day

20161010  is Holiday#:  7 Columbus Day

20161111  is Holiday#:  8 Veterans Day

20161124  is Holiday#:  9 Thanksgiving Day

[SNIP]...

 

Links:

FileExists

See Also:

General, File & Disk, Test Object Functions

 


Edit Time: 9/21/2020 2:38:31 PM


Topic ID#: 696

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software