python read a file into a list or array code example
Example 1: how to read a file into array in python
def readFile(fileName):
fileObj = open(fileName, "r") #opens the file in read mode
words = fileObj.read().splitlines() #puts the file into an array
fileObj.close()
return words
Example 2: python read file into a list
f = open(filename, "r")
listItems = f.read().splitlines()