Write text data to array between boundaries <p>I have a problem which i hope you can help me solve! I have a txt that looks like:</p> <pre><code>A100 1960 3 5 6 7 8 9 10 11 12 13 A200 1960 3 5 6 7 8 9 10 11 12 13 14 15 A300 1960 3 5 6 7 8 9 10 11 12 13 14 15 16 17 </code></pre> <p>I want to search for the keyword for example <code>A200 1960</code>. Now I want to save all numbers between <code>A200 1960</code> and <code>A300 1960</code> in an <code>array(x, y)</code>.</p> <p>I managed to skip to the line I want. The problem now is to write to the array until line <code>A300 1960</code>. Also the length of the array can variate.</p> <pre><code>def readnumbers(filename,number,year): number_year = np.asarray([]) f = open(filename) lines = f.readlines() f.close() strings_number = 'A'+ str(number) strings_year = ' ' + str(year) STARTER = strings_number+ '' + strings_year start_seen = False for line in lines: if line.strip() == STARTER: start_seen = True continue if start_seen == True: parts = line.split() </code></pre>