our DB has a 1000 char limit for a notes field (I think) and I have a script which collates lots of data which I upload to this field. sometimes the data exceeds the length allowed and is not uploaded.
My data entires are stored in a list so what I thought it is if I count the chars by converting the list to a string, if the chars are greater than 500 for example, split the list at the nearest entry to 500 chars.
I started to build a sample using 20, but im now unsure of how to get the nearest comma to the 20th character, then split the list (id figured id do this part by just creating a new list and have a list within each item of the new list)
>>> d = ['asdasda','2g45hh4gq3g','093jfanasuqh','90DAS82hs']
>>> len(d)
4
>>> len(str(d))
55
>>> results = []
>>> if len(str(d)) > 20:
...
Sample desired output as per the below: sample output in this example would be as per the below, as the 20 char limit in each string falls under the second list item of both
[['asdasda','2g45hh4gq3g'],['093jfanasuqh','90DAS82hs']]
if one of the list items where longer than 20 chars it would look like the below
[['asdasda','2g45hh4gq3g'],['093jfanaiamlongerthan20suqh'],['90DAS82hs']]