The purpose is to parse two text files, and extract information from them to produce a new text file. The script is run as [url removed, login to view] TextFile1 TextFile2 > [url removed, login to view]
Both files are tab delimited text files. Examples are attached.
The only columns we are interested in from TextFile1 are:
Column 1, which is our “TickerName”.
Column 8, which is either “L” or “S”.
The only columns we are interested in from TextFile2 are:
Column 1: This is again our “TickerName”, but appended with the word “Stock”. If we remove the word “ Stock”, we have the same TickerNames in TextFile1 and TextFile2. However, as can be seen in the example above, TextFile1 can have multiple entries for a TickerName.
The [url removed, login to view] is exactly the same as TextFile1, except it has an additional column/field at the end of each row. This is generated in the following manner. If column 8 from TextFile1 is “S”, then the additional field corresponds to column 6 from TextFile2 for the appropriate ticker. For example, from the example above the first ticker is “ANV”, which has “S” in column 8. Therefore, we are interested in column 6 from TextFile2, which is “19.747”.
If Column 8 is “L”, then the additional field corresponds to column 7 for the appropriate ticker. For example, from the example above, the third ticker is “ARIA”, which has “L” in column 8. Therefore, we are interested in column 7 for this ticker from TextFile2, which is “21.42”.
The example above will therefore produce an output identical to the "[url removed, login to view]" example.
The script will produce error messages, for example:
- If the ticker is not found in TextFile2
- If the “L/S” field does not contain and “L” or “S”
32 freelancers are bidding on average $46 for this job
Hello, Your specifications are very clear. I will create a Perl script to parse your data from the 2 files and output the third with the additional field appended. A IDLER