Friends! The essence of the question is this: every 2 minutes, a txt file arrives on the server in the files directory. My task is to process data from this file. Unfortunately, I haven’t had a deal with the files yet, so I don’t know how to work with them correctly, but the deadlines for this assignment are very tight, so you need to start processing it the sooner the better. And most importantly - right.
Here's what's inside the file:
1;i;iazs-v1.1.82 2;P;1;151587;202741;294725;0;0 3;R;1;0;6588;2503;0;7436;1862;0;0 4;R;2;0;5769;2065;-6;7533;1556;0;0 5;R;3;0;15586;7730;-2;8397;6491;0;0 6;T;1;18.04.2016 09:14:08;9;000000000000;255;777;18859;1;1;0;000000000000 7;T;2;18.04.2016 09:14:08;1;00000073487F;255;777;0;1;1;1;000000000000 8;T;3;18.04.2016 09:14:26;9;000000000000;255;777;26000;1;2;0;000000000000 9;T;4;18.04.2016 09:14:26;1;00000073487F;255;777;0;1;2;1;000000000000 10;# Arriving files are always the same, that is, according to the rules of creation, and the number of parameters.
This is what it means: The first digit of a line is a pure line number. Next after ";" This is a data type. They are: P, R, T. The data type i does not need to be processed, this is the firmware version. Each of these data types in a string has parameters that are separated, and their number is always the same.
I, unfortunately, do not know how to implement such a parser, but I imagine it this way: 1) Open the file, 2) We get the data into a loop that ends at the end of the file. 3) Take the string, take the second element - the data type, and then do, for example, switch , with a set of functions depending on the data type. Then I will work with the array in these functions and process the data.
The whole question essentially boils down to this structuring :))