I'm having a bit of trouble working out what sort of loop to use in a program I'm writing.
Basically, I have a file with 2 lists of numbers separated by ";" e.g.
Name ;Magnitude
2713.0;21.546
2713.0;19.564
2713.0;20.102
2713.0;20.959
2714.0;22.031
2714.0;18.46825
2714.0;15.323
2715.0;22.808
2715.0;19.345
2715.0;21.357
2716.0;21.473
on so on up to 4076!
What I want to do is to collect together all the magnitudes that have the same name (i.e. 2714) and put them in an array so I can sort the order of them. (so I have one array containing all the magnitudes for 2713, one for 2714, etc)
I'm reading in one line at a time in a while loop and separating using StringTokenizer. But I can't work out how to put in a loop (or something) that will put the magnitude into an array if its name equals the first number, and if not, increase the number to be the same as the next name and start a new array.
Would be great if someone could help me out! Don't know if it can be done or if I'm making it too complicated. Hope I'm making some sense!
Cheers