November 29th, 2012, 09:44 AM
Load a CSV file to a list
I'm trying to correlate several variables with the following code :
To get this working I need to figure a way of getting the CSV object into a list of values that corrcoef is expecting.
from numpy import corrcoef
from pylab import pcolor, show, colorbar, xticks, yticks
data = csv.reader(open("sales_variables.csv", "rU"))
# plot the correlation matrix
D = corrcoef(data)
Any ideas? I@m very new to Python programming so please excuse my ignorance.
November 29th, 2012, 10:19 AM
You'll need to convert the strings to numbers.
(this improved answer is less stupid)
Last edited by b49P23TIvg; November 29th, 2012 at 10:28 AM.
Reason: Remove stupid answer
[/code] are essential for python code and Makefiles!
November 29th, 2012, 10:50 AM
I got it working by wrapping the data with list ie
d = corrcoef(list(data))