I need to split up a data file that is a database of names, job title and the like into separate lines,and the problem is that the job titles have spaces in their descriptions. I was wondering if there is a way for iss to accept multile spaces as the parameter to break a line. Currently I have this
1 2 3 4 5 6 7 8 9
istringstream iss;
iss.str(names);
do
{
string sub;
iss >>sub;
file2 << sub <<endl;
}
while (iss);
and the problem is it has each word of the job title (all of which are variable lengths) as a separate line. Any Ideas?
You could use std::istream::get() to extract the input character-by-character and write code that detects two (and more than two) consecutive spaces - then just make it do what you want it to do.
The post some data that has the names changed to protect the innocent. But without being able to see exactly how the fields are separated you're asking use to guess about how to parse that string.
How are you getting your input? Is there a delimiter character, a tab char for example, that separates the fields? If not can you alter the data generator to provide some kind of field delimiter?
There is no tab character, the space length is non standard. It is an excel file I have been tasked to add new data to an reformat to no longer include the department.The person before me thought it would be a good plan to just put all the data in one column separated by a few spaces.
I did use bheadmaster's suggestion, but due to bad formatting of the original (always blame the person before you) it was actually more useful to just use my program and edit out the bad data by hand. Thank you all for the help though.