Created
October 15, 2019 20:59
-
-
Save jvcleave/da69dc29c276a01151d9f85126e0c49a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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