I am having headaches with a project handling large databases, its a pain in the bee-hind becuase all the data is formatted differently, its a mess and i am trying to automate tidying it up to generate some useful lists.
The source files are all .CSV, but some of them use the - define strings with "" - method and others don't and just use the comma delimiter to demarcate fields.
Also i have to parse names from the strings and swap them around strip out invalid symbols etc.
The problem i am having is developing a safe or tidy way to use 'str.find_first_of etc,
If the symbol sought is not found then the value returned can mean i then try to subseqently erase out of bounds on the string.
What is a good way of ensuring safely using the value returned by find_first_of, or find_last_of??
I am about to try this, is this the way to check? Even if it is thats still a pain as it has to be done on each operation required with that particular string
Code:
size_t pos = tempStr.find_first_of(',');
if(pos != string::npos)
tempStr.erase(pos); //get rid of all content except the name field