I'd like to perform a function on a a list of data in at text file but I'm not sure how to go about it. My understanding of how to manipulate arrays and strings is weak, that is why I'm doing this project.
My text file looks like:
0, 0. 50 0.5 66;
1, 0. 69 2. 70;
2, 0.5 48 0.5 71;
3, 1. 47 1. 75;
4, 2. 52 1. 74;
5, 2. 71 1. 80;
6, 3. 65 1. 61;
7, 4. 62 1. 68;
I'm looking for a result like this:
0, 0. 50 0.5 66 0. 69 2. 70;
1, 0.5 48 0.5 71;
2, 1. 47 1. 75;
3, 2. 52 1. 74 2. 71 1. 80;
4, 3. 65 1. 61;
5, 4. 62 1. 68;
The second elements of the first two entries is the same (0.)and I'd like to combine these entries onto the same line. The same for lines 4 and 5.
As I understand I must read my file into an array list, but I don't know how to query the array list to find all entries that have the same value for the second element, and then merge the entire entry with another entry.
I have no code to show because I don't know where to begin.
I appreciate any input.