Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to read numbers from a text file in python

with open('file') as f:
    w, h = [int(x) for x in next(f).split()] # read first line
    array = []
    for line in f: # read rest of lines
        array.append([int(x) for x in line.split()])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #read #numbers #text #file #python
ADD COMMENT
Topic
Name
1+9 =