file_handle = open('mynumbers.txt', 'r')
lines_list = file_handle.readlines()
cols, rows = (int(val) for val in lines_list[0].split())
my_data = [[int(val) for val in line.split()] for line in lines_list[1:]]
How to read numbers from file in Python?