Question: For this assignment you will be reading data from a variety of files, verifying that the data is correct, and writing the data out to

For this assignment you will be reading data from a variety of files, verifying that the data is correct, and writing the data out to an output file in a new format.

Your input data will be a series of ASCII text files stored in various subdirectories on a file system. You will need to read data in from each of these files. You will not know in advance the names or locations of the files other than a starting directory.

The data files contain end of day financial information stored in a comma delimited fashion, i.e. CSV or comma separated values. Each file has a .txt extension.

The data files will fall into two categories:

  • Stock data Information on a specific stock.
  • Index data Information on a specific index.

Each file will begin with a header line indicating the data fields for each row (record).

  • Each record will include the following fields:
  • Name as a String
  • Ticker/symbol as a String
  • Date as a String in YYYYMMDD format
  • Open price as a double
  • High price as a double
  • Low price as a double
  • Closing price as a double
  • Volume as an integer

Given a starting directory your program should:

  • Process each file the starting directory any subdirectories
  • For each file your program should process each record excluding the header record.

When processing a record your program should:

  • Verify that each field contains data of the appropriate type
  • If the record appears to be valid you should write a corresponding record to an output file named EODdata.txt. The contents of each record should be written to the output file in a comma delimited fashion as follows:
    • Exchange abbreviation as a string
    • Name as a string
    • Ticker as a string
    • Date in YYYYMMDD format
    • Open as a 2 decimal place double
    • High as a 2 decimal place double
    • Low as a 2 decimal place double
    • Close as a 2 decimal place double
    • Volume as an integer
    • The date the file was last modified in YYYYMMDD format
    • The absolute path to the input file as a string
  • If the record does not appear to be valid you should write a corresponding record to an error file named EODdataERRORS.txt. The contents of each record should be written to the error file in the same comma delimited fashion as used for the valid records. You should check for errors such as:
    • Invalid field, a field that does not contain the correct data type.
    • Incomplete record, a row that is missing one or more fields.
    • Invalid record, a row that has too many records.

The Exchange can be determined from the file name. The characters in the file name before the underscore represent the exchange abbreviation. You will output the abbreviation as the exchange field. For your information the exchanges are:

  • NYSE New York Stock Exchange
  • AMEX American Stock Exchange
  • NASDAQ National Association of Securities Dealers
  • OTCBB Over the Counter Bulletin Board
  • INDEX not an exchange, represent an index file

In addition to writing each record to an output file, each error free records should also be display in the console using a nicely formatted ASCII table.

  • The record that appear in the ASCI table should have fields formatted in the following fashion:
    • Exchange abbreviation as a string
    • Name as a string
    • Ticker as a string
    • Date in YYYYMMDD format
    • Open as a 2 decimal place double with comma thousand separator
    • High as a 2 decimal place double with comma thousand separator
    • Low as a 2 decimal place double with comma thousand separator
    • Close as a 2 decimal place double with comma thousand separator
    • Volume as an integer with comma thousand separator
    • The date the file was last modified in YYYYMMDD format
    • The absolute path to the input file as a string

The width of each of the columns in this ASCII should automatically adjust so that each column will correctly hold its widest values. In this table String values should be left justified in their columns and numeric date should be right justified in their columns. Additionally, each column should have at least two blank spaces before and at least two blank spaces after its values (cell padding).

You must write the ASCII table code as a separate method that:

  • at a minimum, accepts an array of values to be put into the table as a parameter
  • allows for a variable amount of cell padding

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!