I am attempting to open a CSV file that contains 4 columns with about 100 rows. I want to have a 2D numpy array, that sets the first column as the x-coordinates and sets the second column as the y-coordinates.
import numpy as np
dataDocument = open("data.csv")
headers = dataDoument.readline()
def generateArray(dataDocument):
for numbers in dataDocument:
splitDocument = numbers.strip().split(",")
myArray = np.array(splitDocument[0], splitDocument[1])
return myArray
print(generateArray(dataDocument))
I keep getting various error messages, the most common being 'data type "" not understood.' Any suggestions on where my logic error/general code error exists?
returnin theforloop is a definite issue, though)