I have a data conversion question. I'm trying to read a very large space-delimited .txt file (almost 1 million records) and convert the data into a different format, but I can't figure out how best to do it. I don't have much experience reading data from a file.

The data is stored like this...

Code:
 
1 1 
2 
3 2 2 4 2 2 2 3 3 
5 
1 
6 
1 1 
6 
6 7 7 7 6 6 8 8 8 8 
6 9 4 4 4 10 3 10 5 10 4 4 4
and I want it to convert to this...

Code:
 
1
2
2 3 4
5
1
6
1
6
6 7 8
3 4 5 6 9 10
where the existing entries for each record appear in ascending order with no dupilcates. All of the entries are integers between 1 and 17. Each line is a separate record.

I need the new output to be stored in a new .txt file.

I'm sure there's some SQL commands that would probably be easier, but I'm a new programmer and don't have experience with anything outside of C++.

Any suggestions you could give would be greatly appreciated.