I am processing a file that's "named" .csv, but which isn't. It's a
file with values that are separated by tab characters...but there's a
lot of data that isn't data at all. For example, every character is
followed by a '\0' character, and there are non-ASCII characters at the
"front" of the data stream record.
I want to process this file as though it's a comma-separated file,
and I'm cleaning it up with the following code (which works - the data
line goes from 1289 characters to 389 characters):
size_t ttt = 0;
while(ttt < str.length()) // clean up line; replace Tabs w/commas
{
if((
str.at(ttt) > 127) || (
str.at(ttt) < 1)) str.erase(ttt, 1);
else
{
if(
str.at(ttt) == '\t')
str.at(ttt++) = ',';
else ttt++;
}
} // while
There may be other, better ways, to do this. I assume that using an
iterator is one, but I don't know quite how to do so (when to advance
the iterator, etc.). Are there other, better, ways? If so, can someone
show me how? TIA
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus