Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

open textfile separated by whitespaces python

numbers = []

#Open the file
with open('file.txt') as fp:
    #Iterate through each line
    for line in fp:

        numbers.extend( #Append the list of numbers to the result array
            [int(item) #Convert each number to an integer
             for item in line.split() #Split each line of whitespace
             ])

print(numbers)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #open #textfile #separated #whitespaces #python
ADD COMMENT
Topic
Name
2+8 =