So I understand how to manipulate a text file and move data in and out of the program, but I'm trying to take raw data in a text file, and load them into an array that is originally empty, how would I make this approach?
Assume my raw data contains 3 words, I want to place those words into a variable called Array. The raw data of the text file contains the 3 following words: ' Apple Banana Orange '. I would like it to load into the array as: Array = ["Apple", "Banana", "Orange"]. How would you approach this?
with open("C:\\Users\\NameList.txt","r") as f:
Array = []
nameList = f.readlines(Array)
Am aware the code is wrong, but I'm not sure how to fix even after reading so much.
list, they are not referring to a numpy array.Array = open("C:\\Users\\NameList.txt", "r").readlines()?Array = f.readlines().