I have elements like this
# is a comment
speed=/loop= for pre-defined variables e.g speed=100
0 0 0 0 0 0 0 0 a data sequence e.g '1 3 5 2 3 6 2 3'
First I did this
Code: Select all
with open("data.txt") as sequence:
for lineNumber,line in enumerate(sequence):
print(lineNumber)
if ure.match('#',line) == None or ure.match('\n',line) == None:
etc etc
Code: Select all
line = '1 2 3 4 5 6 7 8'
bob = ure.match('(#)? *((speed) *= *([0-9]*))? *((loop) *= *([0-9]*))?( *([0-9]) *([0-9]) *([0-9]) *([0-9]) *([0-9]) *([0-9]) *([0-9]) *([0-9])*)?','line')
for i in range(17):
print("group %d : %s" % (i,bob.group(i)))
Code: Select all
group 0 : 1 2 3 4 5 6 7 8
Traceback (most recent call last):
File "main.py", line 7, in <module>
MemoryError: memory allocation failed, allocating 4262065870 bytes
https://github.com/micropython/micropython/issues/1122
Does anyone have an idea of how I could do this in a far more efficient way? avoiding this issue?