I wrote a program to analyze a log file for a machine that my company repairs.
The program that runs the machine spits output into a text file (.log) and my program will analyze it and return the results of different calculations to the user.
The log file idealy looks like this most of the time
>25 233966 300156 89980 >26 232342 300157 90010 >25 235908 300156 90020 >22 242106 300154 90000
This is ideal formatting and USUALLY is the case. Now out of each of those 4 line "paragraphs" only the first and the last lines (eg >22 and 9000) are analyzed. The middle two lines are ignored. So the program that I wrote reads in 5 line "chunks" until the end of the file. It reads the first line, removes the ">" and stores the value into an int array. It then reads the next 3 lines and stores the last line read into another integer array. After reading is done, the arrays are analyzed and output is displayed to the user.
However, occasionally the program that interacts with the machine spits out random newlines and the formatting is different, like this:
>25 233966 300156 89980 >26 232342 300157 90010 >25 235908 300156 90020 >22 242106 300154 90000 >25 236561 300155 90020 >24 237751 300155 90010
So I am wondering if anyone could give input to me on how to write an algorithm that will read this data correctly regardless of the newlines. Is there a way to read a line and ignore blank lines?
I originally wrote this program in C++ but I made a C# GUI version so that it would be easier for the users to use.