Q: Generate an array of integers from text file of strings on separate lines. Better way? So I have this extremely long .txt file that contains all unordered integers from 0 to 100,000, inclusive. 
Ex of .txt
142142
142421
45454
355
etc...

And after some manipulation I was able to successfully achieve the goal of generating an array from those numbers into a list of strings.
arr = open('/Users/macroot/Desktop/data.txt')
data = []
for line in arr:
    data.append(line)
data

Out[ ]: ['142142\n',
         '142421\n',
         '45454\n',
         '355\n',
         'etc...\n']

Furthermore, I even figured out that I can remove the new line tag and convert each element to an integer.
data = list(map(lambda x: int(x.rstrip()), data))
data

Out[ ]: [142142,
         142421,
         45454,
         355,
         etc...]

Wonderful! Now I can put this into a merge sort algorithm and count some inversions! But wait, what is my question?
Surely there is a better, built in method that reads in a file and does these modifications automatically, right?

A: 
Surely there is a better, built in method that reads in a file and
  does these modifications automatically, right?

Since your file constains a lot of lines, it's a good idea to read the content line by line instead of whole content. But you can simplify this by using a list comprehension.
with open('/Users/macroot/Desktop/data.txt') as f:
     array = [int(line) for line in f]

Also, if you're using numpy library you can apply
array = np.genfromtxt('/Users/macroot/Desktop/data.txt', dtype=np.int32)

which returns a generator.
