I only get 11 items out of ofSplitString

I am trying to split a large text file of lore ipsum text into separate words, but I can only seem to get 11 words out of it.

There are commas periods and spaces, but I am only trying to do this by where the spaces are.

This is the basics of my code in setup:

ofBuffer buffer = ofBufferFromFile("lorem.txt");

textData = buffer.getText(); // let's see what it says

and in draw:

vector<string> words;
words = ofSplitString(textData, " "); // split the same text into words

int startX = 0;
int startY = 25; // (rough height of font)
for (int i=0; i<words.size(); i++){
string thisWord = words[i];
    ofRectangle testRect = myFont.getStringBoundingBox(thisWord,0,0);
    newWidth = testRect.width;
    myFont.drawString(words[i],startX, startY);
    startX = startX+newWidth;
    if (startX>ofGetWidth()){
        startX = 0;
        startY = startY+25;
    }
}

Given a typical large amount of text I only get the first eleven words. Am I missing something?

Right before this I am slicing the entirety into individual letters but that seems to be working properly.

I am drawing a human form with letters, but wanted words to appear where you are touching the screen.

What is the size of your words vector ? Is it 11 or you see only 11 words on screen ?
Same goes for your textData, if you print it, does it show all your lorem ipsum thing ?

(Unrelated) Note: you should probably avoid splitting the string in the draw function, once for all at the loading of the text would give better performance.

@silverbahamut is right. Try to output the size of your vector with:

cout << "size of vector is = " << words.size() << endl;

maybe putting in a threadedfunction is better, and i suggest also as @silverbahamut says to not put the ofSplitString in the draw().

hello, im trying to analyze a string of word to, however i think the split function works with spaces and my text doesn’t have, somebody know how i can acces a certain part, bellow is my code, and below that my data string…

void ofApp::setup(){
    resp = ofLoadURL("https://api.thingspeak.com/channels/350905/fields/1.json?
    api_key=MTK6T8XV424RLQTD&results=1");
    textData.clear();
    textData = resp.data.getText();
    words.clear();
    words = ofSplitString(textData, " ");
}

void ofApp::draw(){
    cout << words.size() << endl;
}

{“channel”:{“id”:350905,“name”:“test”,“latitude”:“0.0”,“longitude”:“0.0”,“field1”:“Field Label 1”,“created_at”:“2017-10-23T11:23:35Z”,“updated_at”:“2017-10-23T16:08:15Z”,“last_entry_id”:47},“feeds”:[{“created_at”:“2017-10-23T16:08:15Z”,“entry_id”:47,“field1”:“76”}]}

i need to know the 76 part at the end, if i split it up with splitstring i get 3 parts and i still can’t acces the 76 part, anybody know a solution.
i think splitting everyting up in letters and checking the last ones is gonna work fine but i don’t know how to do that.

thanks for reading

This looks like a JSON string.
I suggest you use ofLoadJson() instead. It will be much easier to deserialize json than parsing the string manually.