I decided to try my hand at C++ in order to get this done.
I have a source text file that is formatted like this:
15:20:35.334 Race /myfolder/racenumber3234.rdc, /myfolder/racenumber3234.rdc, BUS ENGINE, VER TAT124
MORE RANDOM INFO
0: AC45 F678 00E4 65D2 BLOCK 4, 197 Words (15:20:35.334)
4: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
24: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
44: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
64: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
84: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
104: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
124: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
144: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
164: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
184: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
15:20:44.645 Race /myfolder/racenumber3234.rdc, /myfolder/racenumber3234.rdc, BUS ENGINE, VER TAT124
MORE RANDOM INFO
0: AC45 F678 00E4 65D2 BLOCK 4, 197 Words (15:20:44.645)
4: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
24: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
44: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
64: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
84: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
104: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
124: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
144: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
164: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
184: 0001 5476 F432 E456 3214 F83E F436 B23A 68C3 F84E EEE7 DF43 45CB 98CE 31BD B345 CAEF 43ED 4E5C 4556
This sample might be too big, so let me know if I'm breaking some kind of rule.
It's not exactly like this, as it has hundreds of blocks like this instead of just 2, that are different. I just made one up and pasted it 2 times to demonstrate the algorithm that I want to use and need help refining.
The algorithm for extracting what I need is going to be like this:
The first 2 lines(the ones that have a timecode, file location info, bus, and "more random info". Can be discarded pretty much.
The first 4 hex codes starting at 0: can be discarded, as well as the first hex code immediately after the 4:
I figure i can extract the timecode I need from the one located in parenthesis.
Basically, after those entries I discussed are discarded, starting from the 6th hex code basically, I need to make it so that the 6th hex code, the 9th code, and the 12th code and so on are rearranged in a column grouped together. The 7th, 10th, and 13th in another, and the 8th 11th and 14th.
I figure I can use arrays to do this. But the problem I'm having is discarding the things that need discarded, while also parsing the hex codes into the arrays.
This is what I have so far code wise. I don't have much experience yet with this.
Code:#include <iostream> #include <sstream> #include <fstream> using namespace std; int main() { string line; ifstream myfile; ofstream myfile; myfile.open("input.txt"); myfile2.open("output.txt"); while (myfile.good() ) { getline(myfile,line); myfile2<<line<<endl; } myfile.close(); myfile2.close(); return 0; }