Is this just a one-time task? If you don't mind using scripting languages it's pretty easy...
Code:
$ cat /tmp/input
QF File
47.0030 output1
A B Long Result
659.6406 107.3926 37.0000 0
659.8189 107.4216 37.0100 0
659.9972 107.4506 37.0200 0
660.1755 107.4797 37.0300 0
660.3538 107.5087 37.0400 0
$ awk '{ print $1 "," $2 "," $3 "," $4 }' /tmp/input
QF,File,,
47.0030,output1,,
A,B,Long,Result
659.6406,107.3926,37.0000,0
659.8189,107.4216,37.0100,0
659.9972,107.4506,37.0200,0
660.1755,107.4797,37.0300,0
660.3538,107.5087,37.0400,0
$
Just as an example. In C++ I'd do something similar to manasij, except without fancy stream iterators...
Code:
std::string line;
std::getline(std::cin, line);
// now let's make a stringstream out of "line"
std::istringstream stream(line);
// okay, so read 4 words from the stringstream. If there are fewer than 4, we'll get empty strings.
std::string word;
for(int i = 0; i < 4; i ++) {
word = "";
stream >> word;
std::cout << word;
if(i + 1 < 4) std::cout << ",";
}
Something like that.