python - Loadfile, specific lines from .txt file into array -
i have .txt file , need open , create array (in python). however, not want select lines array, first line.
for example, .txt file reads:
1 1 1 1 4 6 4 5 6 8 9 7
and, create array such that, can assign like:
y= array([[1, 4, 6], [4, 5, 6], [8, 9, 7]])
i need generalize future files create array omits first line of text.
you do
with open(file) f: y = [map(int, line.split()) line in f.readlines()[1:]]
notice [1:]
grabs other lines except first one.
Comments
Post a Comment