Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: pydub audiosegment to numpy array 
Python :: mid-point circle drawing 
Python :: convert decimal to float in python 
Python :: python json nan 
Python :: reverse list in python 
Python :: shared SHMEM python 
Python :: join two strings python 
Python :: create a list of pandas index 
Python :: binary search tree python 
Python :: merge sort python 
Python :: h2o ai python 
Python :: installing intel-numpy 
Python :: mistborn books 
Python :: python code for binary search tree 
Python :: python - sending mail 
Python :: python dictionary delete based on value 
Python :: python format decimal list 
Python :: sleep your computer python 
Python :: função anonima python 
Python :: Tuple: Create tuple 
Python :: first step creating python project 
Python :: pandas convert column to title case 
Python :: read csv limit rows python 
Python :: how to check if text is lower in python 
Python :: list comprehension with square numbers python 
Python :: python source code 
Python :: python dlib 
Python :: add two dataframes together 
Python :: python iterating over a list 
Python :: program to demonstrate encapsulation in python 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =