You might be able to use something along the lines of the update in my answer to another question here to group the string of digits in each number. Specifically using this code with the number string as the iterable and a value of 3 for the n
(group-size) argument:
from itertools import izip
def grouped(iterable, n):
"s -> (s0,s1,s2,...sn-1), (sn,sn+1,sn+2,...s2n-1), (s2n,s2n+1,s2n+2,...s3n-1), ..."
return izip(*[iter(iterable)]*n)
digits = '283283283283283283283283284284284284284284284284284284284284284284284284284\n'
print map(''.join, grouped(digits.strip(), 3))
Output:
['283', '283', '283', '283', '283', '283', '283', '283', '284', '284',
'284', '284', '284', '284', '284', '284', '284', '284', '284', '284',
'284', '284', '284', '284', '284']
I note however that the last line of the data in your example, the:
'294294294294294294294294295295 lat = -89.5\n'
is not simply a string of digits, so it will have to be handled as a special case.
Update:
OK, now that I see the additional information you added to your question, I can provide a complete solution for you based on the grouped()
function from my other answer, as I initially suggested. This handles the special line which occurs periodically in your input data by splitting up each line of data and then ignoring all but the first -- often the only -- item of that, which is always a string of digits which are then further processed via my function.
from itertools import izip
def grouped(iterable, n):
"s -> (s0,s1,s2,...sn-1), (sn,sn+1,sn+2,...s2n-1), (s2n,s2n+1,s2n+2,...s3n-1), ..."
return izip(*[iter(iterable)]*n)
data = [' 283283283283283283283283284284284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284284284284284284284284284284284284284283283283\n', ' 283283283283283283283283283283283283283283283283283283283283283283283283283\n', ' 283283283283283283283283283283283283283283283283283283283283283283283283283\n', ' 283283283283283283283283283283283283283283283283283283283283283283283283283\n', ' 283283283283283282282283283282282282282283283283283283283283283283283283283\n', ' 283283283283283283283283283283283283283283283283283283283283283284284284284\n', ' 284284284284284284284284284284284285285285285285285285285285285285285285285\n', ' 285285286286286286286286286287287287287287287288288288288288288288288288288\n', ' 288289289289289289289289289290290290290290290290290290291291291291291291291\n', ' 291291292292292292292292293293293293293293293293293293293293294294294294294\n', ' 294294294294294294294294295295 lat = -89.5\n', ' 284284284284284284284284284284284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284283283284284284284284284284284284284284284283\n', ' 283283283283283283283283283283283283283283283283283283283283283283283283283\n', ' 283283283283283283283283283283284284284284284284284284284284284284284284284\n', ' 284284284284284284284284284284284284283283283283283283283283283283283283283\n', ' 283283283283283283283283283283283282282282282282282282282282282282282282281\n', ' 281281281281281281281281281281281281281281281281280280280280280280280280279\n', ' 279279279279279279279279279279279279279279278278278278278278278278278278278\n', ' 277277278278278278278278278278278278278278278278278278278278278278278278278\n', ' 278278279279279279279279279279279279279279279279279279279279279279279279279\n', ' 279279280280280280280280280280280280280280280280280280280281281281281281281\n', ' 281282282282282282282282283283283283283283284284284284284284285285285285285\n', ' 286286286287287287287288288288288288288289289289289289290290290290291291291\n', ' 292292292292292292293293293293293293293293293294294294294295295295295295295\n', ' 296296296296296296296297297297 lat = -88.5\n']
DU = []
for line in data:
DU.extend(map(''.join, grouped(line.strip().split()[0], 3)))
print DU
Output:
['283', '283', '283', '283', '283', '283', '283', '283', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '282', '282', '283', '283', '282', '282', '282', '282', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '285', '286', '286', '286', '286', '286', '286', '286', '287', '287', '287', '287', '287', '287', '288', '288', '288', '288', '288', '288', '288', '288', '288', '288', '288', '289', '289', '289', '289', '289', '289', '289', '289', '290', '290', '290', '290', '290', '290', '290', '290', '290', '291', '291', '291', '291', '291', '291', '291', '291', '291', '292', '292', '292', '292', '292', '292', '293', '293', '293', '293', '293', '293', '293', '293', '293', '293', '293', '293', '294', '294', '294', '294', '294', '294', '294', '294', '294', '294', '294', '294', '294', '295', '295', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '283', '283', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '284', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '283', '282', '282', '282', '282', '282', '282', '282', '282', '282', '282', '282', '282', '282', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '281', '280', '280', '280', '280', '280', '280', '280', '280', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '277', '277', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '278', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '279', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '280', '281', '281', '281', '281', '281', '281', '281', '282', '282', '282', '282', '282', '282', '282', '283', '283', '283', '283', '283', '283', '284', '284', '284', '284', '284', '284', '285', '285', '285', '285', '285', '286', '286', '286', '287', '287', '287', '287', '288', '288', '288', '288', '288', '288', '289', '289', '289', '289', '289', '290', '290', '290', '290', '291', '291', '291', '292', '292', '292', '292', '292', '292', '293', '293', '293', '293', '293', '293', '293', '293', '293', '294', '294', '294', '294', '295', '295', '295', '295', '295', '295', '296', '296', '296', '296', '296', '296', '296', '297', '297', '297']
You could make an efficient fairly unreadable list comprehension out of it like this:
from itertools import chain
DU = list(chain.from_iterable(map(''.join, grouped(line.strip().split()[0], 3))
for line in data))