Skip to content

Instantly share code, notes, and snippets.

@jvcleave
Created October 15, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvcleave/da69dc29c276a01151d9f85126e0c49a to your computer and use it in GitHub Desktop.
Save jvcleave/da69dc29c276a01151d9f85126e0c49a to your computer and use it in GitHub Desktop.
string filePath = “data.csv”;
ofFile file(filePath);
if(!file.exists()){
ofLogError(“The file ” + filePath + ” is missing”);
}
ofBuffer buffer(file);
vector<string> lines;
int counter = 0;
//Read file line by line
for (ofBuffer::Line it = buffer.getLines().begin(), end = buffer.getLines().end(); it != end; ++it) {
string line = *it;
lines.push_back(line);
counter++;
}
ofLog() << “finshed: ” << counter << ” lines: ” << lines.size();
vector<string> words;
for (size_t i=0; i<lines.size(); i++)
{
vector<string> lineContents = ofSplitString(lines[i], “,”);
for (size_t j=0; j<lineContents.size(); j++)
{
words.push_back(lineContents[j]);
}
}
ofLog() << “words: ” << words.size();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment