I've got a CSV file that I'm processing using the opencsv library. So I can read in each line. The particular transformation I need to do requires me to sort that file first before I run through it with the main portion of my java file.
e.g.
5423, blah2, blah
5323, blah3, blah
5423, blah4, blah
5444, blah5, blah
5423, blah6, blah
should become
5323, blah3, blah
5423, blah2, blah
5423, blah4, blah
5423, blah6, blah
5444, blah5, blah
etc..
The reason i need to do this is I'm combining all rows with the same id and outputting them to a new file.
Anything wrong with:
Read each line of the csv with the opencsv library
Add them to a 2 dimensional array
Run some sort of sorting on this
Loop through sorted array and output to file.
Any other ideas on this and what is the best way to sort the data?
Bit rusty on my Java.
UPDATE: To Clarify on the final output
It would look like:
5323, blah3, blah
5423, blah2!!blah4!!blah6, blah
5444, blah5, blah
This is a very simplified version of what I'm doing. It actually is needed for multi option fields in a JBase system. This is the requested file format.
There are over a 100,000 lines in the original file.
This will be run more than once and the speed it runs is important to me.