I'm trying to seperate out some numbers from a large text file and place those numbers in a formated fashion inside another text file. I'm working in MS Visual C++. The file i'm reading from has lines line the following:
AT BUS [CALN HHG000 138.00] 77904 AREA 7 (KV L-G) V+: / 0.000/ 0.00 (KV L-G) VA: / 0.000/ 0.00 V0: / 42.250/ 178.86
THEV. R, X, X/R: POSITIVE 0.03296 0.13488 4.093 NEGATIVE 0.03297 0.13493 4.092 ZERO 0.08720 0.30104 3.452
I need the 77904 from the first line and the first two numbers after "POSITIVE" and "ZERO" on the second line. This format of text is always the same because a computer program generates a large .txt file with all these numbers in it and rather than sort through it and copy the numbers by hand, i'd rather write a text file that grabs those fields i need and shoves them into a txt file seperated by commas or tabs so that i can easily import them into Excel. Here's my code:
Thanks for your help. Perhaps that is a good idea. That part of the code is meant to grab the number associated with a power bus (I'm an intern working for a power distribution company) by reading through a Report File generated by some in-house software. I took a look at the format of this report and noticed that the bus number always appeared between the character ']' and the word 'AREA'. My intention with this code was to scan a line from the report file into memory and have the computer run through it looking for these characters in the correct order. Since they don't occur on other lines paired together like the lines that contain the bus number, I could safely have the computer ignore the lines where only one or neither of these 'markers' occur. When both markers are found i wanted the program to grab the string in between the two location of the markers and dump it into a char array and strip away the white space and throw the remaining characters into a file, to which the program would append some other numbers i wanted to grab from the report as well, but for now, i'm just trying to tackle grabbing the bus numbers. As to your suggestion: If i loaded the string in between ']' and 'AREA' using std::substr (from the example in my OP this string would read: "_77904_" where the underscores represent whitespace) could i remove that whitespace?