In my current django project I have a model that stores very long strings (can be 5000-10000 or even more characters per DB entry) and then i need to split them when a user is calling the record (it really need to be in one record in the DB). What i need is it to return a list (queryset? depends if in the “SQL” part or getting all the list as is and doing the parsing in the view) of shorter strings (100 – 500 characters per sting in the list i return to the template).
I couldn’t find anywhere a python split command nor example or any kind of answer for that….
I could always count words and append but count words…. but i am sure there has to be some kind of function for that sort of things….
EDIT: thank you everyone, but i guess i wasn’t understood,
Example:
The String: “This is a very long string with many many many many and many more sentences and there is not one character that i can use to split by, just by number of words”
the string is a textField of django model.
i need to split it, lets say every 5 words so i will get:
[‘This is a very long string’,’with many many many many’,’and many more sentences and’,’there is not one character’,’that i can use to’,’split by, just by number’,’ of words’]
The thing is that is almost every programming languages there is split per number of words” kind of utility function but i can’t find one in python.
thanks,
Erez
1 Answer